Backups: backups

backups copies every committed transaction to directory targets and restores a database from them. It requires database with a path or temporary setting; without storage each backups/ request fails with no_database. The CLI selects it only from a --config file, never by default. A target keeps the full history, so a restored database has the same transactions and the same as-of results. A target also keeps the objects payloads that the history names, each chunk once, and a restore publishes them before the facts that hold them; restoring such a history needs objects. backups cannot be selected with retention.

SettingPurposeDefault
targetsA map of target names to target maps.No targets
bypass-unreachableWhen true, a target that the plugin cannot reach does not hold writes.false
restore-throughRestore a new database from the targets, up to and including this transaction ID.None

A target map has file {path "<directory>"} and, optionally, compression {algorithm "zstd" level 3}, encryption-key (64 hexadecimal digits) and maximum-lag (transactions, logical-bytes, binary-bytes or a #dur duration). The configuration holds the key. Status and errors never show it.

The file target is not available on Windows. There, a configuration with a file target refuses the open with backups: the file target is not supported on Windows. The target needs POSIX file operations to keep each backup durable: links that never replace a file, flushed directories and private files with mode 0600.

Dependencies

Configuration

Select this plugin explicitly when opening the database:

TRON253 B
Offset (hex)Bytes (hex)Meaning
0054 52 4F 4Emagic TRON
044C 70617468txt "path"
096C 6170702E6462txt "app.db"
100F 0A 04000000 0900 0000map leaf, size 10: @4 → @9
1A4C 70617468txt "path"
1F14 10 2F7372762F62 61636B7570732F61 7070txt "/srv/backups/app"
310F 0A 1A000000 1F00 0000map leaf, size 10: @1A → @1F
3BCC 7472616E736163 74696F6E73txt "transactions"
4802 64000000000000 00i64 100
510F 0A 3B000000 4800 0000map leaf, size 10: @3B → @48
5BBC 6D6178696D756D 2D6C6167txt "maximum-lag"
670F 0A 5B000000 5100 0000map leaf, size 10: @5B → @51
714C 66696C65txt "file"
760F 0A 71000000 3100 0000map leaf, size 10: @71 → @31
8007 0E 00480000 6700 0000 76000000map branch, size 14, depth 0 (root), slots 11, 14: @67 → @76
8E5C 6C6F63616Ctxt "local"
940F 0A 8E000000 8000 0000map leaf, size 10: @8E → @80
9E7C 74617267657473txt "targets"
A60F 0A 9E000000 9400 0000map leaf, size 10: @9E → @94
B07C 6261636B757073txt "backups"
B80F 0A B0000000 A600 0000map leaf, size 10: @B0 → @A6
C28C 64617461626173 65txt "database"
CB0F 0A C2000000 1000 0000map leaf, size 10: @C2 → @10
D507 0E 00140000 B800 0000 CB000000map branch, size 14, depth 0 (root), slots 10, 12: @B8 → @CB
E37C 706C7567696E73txt "plugins"
EB0F 0A E3000000 D500 0000map leaf, size 10: @E3 → @D5

Usage

The plugin copies new transactions in the background. When a target falls behind past a maximum-lag limit, or the plugin cannot reach it, new writes wait until the target catches up. To restore, open an empty database with the same settings. Send backups/sync with params {max-wait #dur "PT30S"} to wait up to 30 seconds for completion. It returns {} when the restore is complete, or backup_sync_timeout if the wait ends first. Without max-wait, it checks once. To restore only up to a transaction, open a new database path with restore-through. The plugin then only reads the targets. After the restore it stops using them, and the new database admits writes. Use new targets for the restored database. backups/status reports each target, and backups/verify checks every target again. The Backups section of the ABI reference gives the complete settings, the write holds and the refusal reasons.

binary-bytes counts distinct raw list and object chunk records (kind byte plus payload) that the target cannot yet read. Shared chunks and repeated payloads count once across the whole backlog; readable target copies count zero. Payload chunk-list metadata and compression or encryption overhead do not count. The worker measures this lag outside commits; a new commit invalidates it and holds the next write until measured. Status includes lag.binary-bytes only for a target with that limit configured and its measurement current.

Creating a new target root can leave a private pending-creation file in its nearest existing ancestor until the directories are durable. Retry the same path after a failed creation. Existing roots need only traversal permission on their ancestors. A read-only restore source refuses pending creation instead of repairing it.

Contributions

Requests

  • backups/status
  • backups/sync
  • backups/verify