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:
{:plugins {:database {:path "app.db"}
:backups {:targets {:local {:file {:path "/srv/backups/app"}
:maximum-lag {:transactions 100}}}}}}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