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.
| Setting | Purpose | Default |
|---|---|---|
targets | A map of target names to target maps. | No targets |
bypass-unreachable | When true, a target that the plugin cannot reach does not hold writes. | false |
restore-through | Restore 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:
| Offset (hex) | Bytes (hex) | Meaning |
|---|---|---|
| 00 | 54 52 4F 4E | magic TRON |
| 04 | 4C 70617468 | txt "path" |
| 09 | 6C 6170702E6462 | txt "app.db" |
| 10 | 0F 0A 04000000 0900 0000 | map leaf, size 10: @4 → @9 |
| 1A | 4C 70617468 | txt "path" |
| 1F | 14 10 2F7372762F62 61636B7570732F61 7070 | txt "/srv/backups/app" |
| 31 | 0F 0A 1A000000 1F00 0000 | map leaf, size 10: @1A → @1F |
| 3B | CC 7472616E736163 74696F6E73 | txt "transactions" |
| 48 | 02 64000000000000 00 | i64 100 |
| 51 | 0F 0A 3B000000 4800 0000 | map leaf, size 10: @3B → @48 |
| 5B | BC 6D6178696D756D 2D6C6167 | txt "maximum-lag" |
| 67 | 0F 0A 5B000000 5100 0000 | map leaf, size 10: @5B → @51 |
| 71 | 4C 66696C65 | txt "file" |
| 76 | 0F 0A 71000000 3100 0000 | map leaf, size 10: @71 → @31 |
| 80 | 07 0E 00480000 6700 0000 76000000 | map branch, size 14, depth 0 (root), slots 11, 14: @67 → @76 |
| 8E | 5C 6C6F63616C | txt "local" |
| 94 | 0F 0A 8E000000 8000 0000 | map leaf, size 10: @8E → @80 |
| 9E | 7C 74617267657473 | txt "targets" |
| A6 | 0F 0A 9E000000 9400 0000 | map leaf, size 10: @9E → @94 |
| B0 | 7C 6261636B757073 | txt "backups" |
| B8 | 0F 0A B0000000 A600 0000 | map leaf, size 10: @B0 → @A6 |
| C2 | 8C 64617461626173 65 | txt "database" |
| CB | 0F 0A C2000000 1000 0000 | map leaf, size 10: @C2 → @10 |
| D5 | 07 0E 00140000 B800 0000 CB000000 | map branch, size 14, depth 0 (root), slots 10, 12: @B8 → @CB |
| E3 | 7C 706C7567696E73 | txt "plugins" |
| EB | 0F 0A E3000000 D500 0000 | map leaf, size 10: @E3 → @D5 |
| F5 | EB000000 00000000 | root → @EB; previous: none |
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/statusbackups/syncbackups/verify