benbjohnson / litestream

Streaming replication for SQLite.
https://litestream.io
Apache License 2.0
11.1k stars 256 forks source link

restore fails with age encrypted backup over sftp #603

Closed tionis closed 2 months ago

tionis commented 2 months ago

On restore it seems to fail parsing some header:

time=2024-08-31T03:29:56.615+02:00 level=INFO msg="restoring snapshot" db=/data/denokv.sqlite3 replica=sftp generation=6957b586b4294bae index=0 path=/data/denokv.sqlite3.tmp
time=2024-08-31T03:29:56.717+02:00 level=ERROR msg="failed to run" error="cannot restore snapshot: failed to read header: parsing age header: unexpected intro: \"\\x04\\\"M\\x18dp\\xb9\\x18\\x04\\x00\\x00\\xf6\\x12SQLite format 3\\x00\\x10\\x00\\x02\\x02\\x00@  \\x00\\x00\\x00\\x03\\x00\\x00\\x00\\v\\x00\\x01\\x00U\\v\\x00\\x00\\x00\\x04\\x0e\\x00G\\x00\\x00\\x01\\x00\\r\\x00\\x0f\\x02\\x00\\x04\\xff\\x12\\x03\\x00.j\\xd0\\r\\x0e^\\x00\\n\""
mohammed90 commented 2 months ago

The backup you're restoring is not encrypted

\x12SQLite format 3

It's plaintext

tionis commented 2 months ago

Ah didn't notice that. Let me look into that.

tionis commented 2 months ago

But why though? That's my config:

dbs:
  - path: /data/denokv.sqlite3
    replicas:
      - type: sftp
        host: my-host:22
        user: my-user
        path: litestream/denokv
        key-path: ${HOME}/.ssh/id_ed25519
        age:
          identities:
            - ${AGE_PRIVATE_KEY}
          recipient:
            - ${AGE_PUBLIC_KEY}
tionis commented 2 months ago

Nevermind :sweat: the correct config option for encryption is recipients not recipient