Commit Graph
1 Commits
Author SHA1 Message Date
Lauri Ojansivu 5ef5757c71 Continuous backup: encryption at rest, cloud upload, and a SQLite restore applied on restart.
As decided on 2026-10-03:

- Encryption: with Encrypt on, the built-in engines seal what they store -
  segments, page deltas, bases, blobs and state - with AES-256-GCM from
  Node's crypto. The key is a file the administrator holds outside the
  target and everything the stream reads, never in the database: 64 hex
  characters, or a passphrase stretched with scrypt and the stream's salt.
  stream.json keeps the salt and an HMAC check, so a wrong key is refused
  on save and before a restore; blob names are keyed HMACs; a generation
  records whether it is encrypted and is refused without its key.
- Cloud upload: the target is mirrored to S3/MinIO, Azure or GCS with the
  Attachments storage panes' adapters and credentials. Sealed files go up
  once, and an index or generation file again after the files it names, so
  the remote copy never lists a segment it lacks; retention removals follow,
  a failed upload is retried, and Fetch from cloud fills a lost target.
- SQLite restore on restart: a rebuilt, checked wekan.sqlite is staged in
  <db>/continuous-restore with RESTORE_REQUESTED "continuous". The Docker
  entrypoint, start-wekan.sh and the Snap keep the live database and its WAL
  in continuous-restore/replaced first, then copy the staged one in, before
  FerretDB opens its files. A pending request is never overwritten.

Tests: tests/continuousBackupEncryption.test.cjs, tests/continuousBackupCloud.test.cjs,
tests/continuousBackupRestartRestore.test.cjs (each script's real restore
block in a sandbox), encrypted integration tests on a real replica set and
WAL database, the server methods, and the pane in Chromium and WebKit.

Thanks to xet7 !
2026-10-03 08:52:16 +03:00