Backup and restore
You run Community Edition and want backups you can restore on a new box, or you have lost a box, a database or a key, or you need to know what a dedicated instance keeps and who restores it.
UPDATED
Community Edition backs itself up with two commands in the platform image, backup and restore, since platform 0.245.0. The reference compose file runs them as services: a scheduler, a one-shot before every upgrade, and a restore you start yourself. This page says what each one does. A dedicated instance is backed up by Azure, and optionally by a nightly bundle of its own: see the last section.
What a bundle holds
One backup run writes one bundle: a folder with a signed manifest that lists every file in it with its size and SHA-256.
- The database, as a dump cut into 64 MiB segments, each encrypted to your recipient certificate. A restore needs every segment, so copy a bundle folder whole.
- The platform’s keys, in one envelope encrypted the same way: the audit span signer, the instance identity key agents pin, the device CA key, the catalog attestation keys, the Data Protection key ring, the backup signing key and, with the Caddy overlay, Caddy’s data, its internal CA included. The database and the keys that signed what it holds travel together, so the audit signatures still verify after a restore.
- The database roles, without passwords, and the list of installer files the database refers to.
- The installer files themselves sit on a shelf beside the bundles, shared by all of them and not encrypted: they are public vendor installers and the MSIs built from them, and the signed manifest covers their integrity.
A bundle appears only once the run has read every file back and matched its digest. Not in it: .env, the compose files with their postgres/ and caddy/ folders (and any TLS certificate you put there), and your private key. Keep those together, off the box.
The recipient key, kept off the host
backup keygen --out <folder> writes a recipient certificate and its private key, RSA-3072 with nothing to choose, and prints the certificate’s SHA-256 fingerprint. It refuses to write into the platform’s data volume or the backup folder, and it never overwrites an existing pair. --protect-key <file> encrypts the private key under a passphrase read from a file; a restore then needs that file too.
The certificate goes where the backup services read it (WEP_BACKUP_RECIPIENT_CERT_FILE in .env, by default ./backup-recipient.crt). The private key leaves the box. It is the only thing that opens your bundles, and a key left on the box sits beside the bundles it opens.
The first backup mints a backup signing key in the wep-backup-state volume and prints its fingerprint. Every bundle is signed with it. Record the fingerprint beside the private key: a restore on a new box asks for it. The console’s storage page (/community/settings/storage) shows it too. If that volume is lost while the database still records backups, backups refuse to mint a new signing key until a run passes --rotate-signer, and restores then need the new fingerprint.
A box with no certificate can still take a backup by hand with --passphrase-file. That bundle carries a key of its own, encrypted under the passphrase, and the passphrase alone opens it. The scheduler and the pre-upgrade backup never read a passphrase.
Schedules
The backup command gained a scheduler in platform 0.246.0, and the reference compose file runs it as the wep-backup service, so docker compose up -d starts it. It takes backups once the stack has a recipient certificate, and three settings in .env drive it:
| Setting | Default | Meaning |
|---|---|---|
WEP_BACKUP_SCHEDULE |
daily |
hourly, daily, or weekly (every Sunday). hourly since platform 26.11.1500 |
WEP_BACKUP_AT |
02:00 |
When each backup starts, in UTC. With hourly only the minute counts: :15 runs at a quarter past every hour |
WEP_BACKUP_KEEP |
14 |
How many hours, days or weeks of scheduled bundles to keep, by the schedule, 1 to 1000. With hourly, 24 keeps a day |
- What it keeps. Since platform 26.11.1500, scheduled bundles are kept by their signed snapshot time, in UTC. With
daily, it keeps the newest bundle of each of the newestWEP_BACKUP_KEEPdays that hold one, and withweekly, of that many weeks, Monday to Sunday. Withhourly, it keeps the newest bundle of each of the newestWEP_BACKUP_KEEPhours that hold one, and also of each of the newest 14 days and 14 weeks. An hour, day or week with no backup does not count, so a long break in backups does not age out the bundles before it. It also keeps the newest three pre-upgrade bundles. It never removes a bundle you took by hand, and it counts only bundles its own signer signed, so a folder someone puts among the bundles neither counts nor goes. - Changing the schedule. A change never removes a bundle the old schedule would still keep. The scheduler records what the old schedule kept in
retention-schedule.json, in thewep-backup-statevolume. Each scheduled bundle from before the change then stays as long as the old schedule would have kept it. If that file cannot be read, retention removes no scheduled bundle until you remove the file, and the scheduler’s log says so. - Catching up. When the newest successful backup is more than one interval old, or there is none, it takes one within 2 to 10 minutes of starting.
- Retries. A backup that failed for a reason that waiting can fix, such as a database that did not answer, is tried again up to three times, 30 to 60 minutes apart (5 to 10 minutes with
hourly), never at or past the next scheduled backup. A refusal that waiting cannot fix, such as a missing certificate, waits for the next scheduled backup. - No certificate, no backups. The scheduler keeps running and writes nothing, and the storage page says backups are not configured.
- Watching it. The storage page shows the last backup, the last bundle a drill verified, the schedule and its next run, and warns when a backup is missing, failed or overdue.
docker compose run --rm wep-backup backup takes one by hand. A backup started while the scheduler is taking one exits 69 and writes nothing.
An hour at most. With WEP_BACKUP_SCHEDULE=hourly, a restore from the newest bundle loses up to an hour of changes, as long as each backup succeeds. Set WEP_BACKUP_KEEP=24 to keep a day of hourly bundles beside the daily and weekly ones. Each run dumps the whole database, but every bundle shares one shelf of installer files, so a run adds only the installers that are new.
Going back to an older image. An image from before 26.11.1500 refuses hourly, and its retention keeps only the newest WEP_BACKUP_KEEP scheduled bundles, so the daily and weekly bundles the hourly schedule kept would go. Before you roll back, set WEP_BACKUP_SCHEDULE=daily, and WEP_BACKUP_KEEP to at least the number of folders in backups/bundles/ (at most 1000). Put both back after you upgrade again.
Where the bundles live. WEP_BACKUP_DIR in .env names the folder, by default ./backups beside the compose file: the same host, and usually the same disk, as the database. A disk that fails takes the backups with it, and a restore then reaches back only as far as your last copy elsewhere. Point WEP_BACKUP_DIR at a second disk or a NAS mount, and copy the folder off the box as well, shelf/ together with bundles/, because a restore puts the installer files back from the shelf.
Restore, pinned to the signer
restore accepts only a bundle signed by the backup signer it expects. On the box that took the bundle, the state volume says which signer that is; on a new box you pass its fingerprint with --expect-signer. With no signer to expect, the restore refuses. Since platform 26.11.1600 --expect-signer also accepts the fingerprint with the spki-sha256: prefix. From the same release a restore or a drill refuses an image without the agent installer up front, with exit 78 (--only keys skips that check), and a restore whose platform fails to start exits 70 with its report.
It works beside the live installation, not over it:
- It loads the dump into a staging database and decrypts the keys into a staging folder.
- It puts the installer files back.
- It migrates the copy forward to the image you run.
- It resets sessions and tokens, and carries post-backup revocations forward.
- It runs a set of offline checks.
- Only when every check passes does it swap the staging database and keys in. What it replaced is kept aside, not deleted.
Its report goes into the backup folder and states the gap window: from the bundle’s snapshot to the restore.
- Onto a new box, run it before the platform first starts there. A platform started first creates keys and a backup signer of its own, and the restore then refuses.
- Over a running installation, stop the platform and the scheduler and add
--replace. It first takes a pre-replace bundle of what it replaces, and keeps the replaced database until you drop it. - Keys only. For a box whose database is intact and whose key files are not,
--only keysadds the missing key files from a bundle and never overwrites one that is there. The platform names this command when it refuses to start on a missing key. - What it needs. The bundle folder and the shelf; your private key; an image that knows every migration in the bundle’s database (an older one refuses with exit 86, a newer one migrates the copy forward); the same application database role as the box the bundle came from; and a PostgreSQL server of the bundle’s major version or newer.
Restore with the restore command, never with pg_dump and psql: a database put back by hand stops the audit projection.
After a restore
Everyone signs in again. Before the swap, the restore revokes every agent session token and every agent enrolment token that could still be redeemed, signs every console session out, and spends every unused broker enrolment token. An agent with a device key re-issues its own token, and the platform admits 50 machines per tenant per day, so 120 such agents are back after three days. The report names the agents without a device key; those enrol again.
When the restore can read the old database (--replace, or --carry-forward-from), it re-applies what was revoked after the snapshot: device-key distrusts, span-key and signing-key revocations, broker certificate revocations, emergency-stop signer removals and a latched emergency stop, and per-user erasures. It reports policy changes made since, without applying them. --no-carry-forward restores away from a change you did not mean, such as a mass distrust, which carry-forward would otherwise bring straight back. With no old database to read, the report says that what changed is unknown, and those changes have to be made again by hand. What that means for personal data is under erasure.
The statements check
Since platform 26.11.1500, every restore and every drill verifies each signed statement in the restored copy again. Agent-signed spans verify under their agent’s key, instance-signed spans under the span signer key, and each attestation under its own key. Each tenant’s totals must also reach the counts the bundle recorded when it was taken, so a bundle that lost statements fails even when everything left in it verifies. A statement that does not verify, or a total that falls short, fails the check with exit 88, and the report names it. The check takes about a minute per million spans with four cores free.
- A bundle taken before 26.11.1400 recorded no counts, so the check cannot tell whether any statement is missing. A drill stops with exit 93 and records the bundle as not verified. Take a new backup and drill that one. A restore stops with exit 93 before it loads anything and prints a phrase. Run the same restore again with
--accept-count-unknown <phrase>to restore that bundle anyway; it still verifies every statement. - Spans signed by a span signer key lost before platform 0.245.0 verify under no key the installation recorded, because it started recording these keys in that version. A drill stops with exit 94. A restore stops at its checks with exit 94 and prints a phrase, and
--accept-unverifiable <phrase>restores that bundle anyway. Any other span that does not verify still fails with exit 88.
The restore drill
restore --drill proves a bundle restores without touching anything live. It loads the bundle into a scratch database on the same server, decrypts the keys into the restore container’s /tmp, which the reference compose file keeps in memory, migrates and checks the copy, re-hashes every installer file the bundle names, and drops all of it at the end. The platform keeps running. Exit 0 means the bundle is complete, your key opens every file of it, and it restores; the storage page records it as Last verified. A failed check exits 88 and records the bundle as not verified, and so do exits 93 and 94 from the statements check.
The drill needs your private key, so nothing runs it on a schedule. Run it after you set backups up, after each upgrade, and every few months. Like a restore, it needs room on the database volume for a second copy of the database.
The pre-upgrade backup, and its override
On every docker compose up, the reference compose file runs a one-shot, wep-backup-pre-upgrade, before the platform, and the platform starts only once it succeeds. The command behind it shipped in platform 0.246.0. When the image you are moving to has migrations to apply, it backs up the database, without installer files, before anything migrates, and keeps the newest three such bundles. Otherwise it does nothing.
- With a recipient certificate the bundle is encrypted and holds the keys. Without one it holds no keys and its dump is not encrypted: anyone who can read the backup folder can read the database. It still rolls this box back, and the console names it.
- If it fails, the platform does not start.
docker compose logs wep-backup-pre-upgradesays why. - The override. Setting
WEP_UPGRADE_WITHOUT_BACKUPin.envto the version you are upgrading to lets that one upgrade go ahead without the backup. The upgrade is recorded in the audit log and shown on the console. Any other value is ignored, so a value left in.envallows no later upgrade. If the override’s audit record cannot be written, it fails closed and the platform does not start. - A compose file without that service still upgrades: the platform migrates, logs a warning and records the upgrade as one made without a backup.
How the pre-upgrade bundle takes you back is under rolling back.
The broker CA through a restore
The broker CA roots sit in the database, their keys wrapped under the Data Protection key ring, so a restore could put an old root back under brokers that have already moved to a new one. Since platform 0.253.0 a Community Edition restore carries the live root table forward whenever it reads the old database and that database is a later state of the same installation, whatever --no-carry-forward says. It wraps each live key again under the restored key ring, and proves every live root unwraps before the swap.
- A bundle that holds a root the live table lacks is refused with exit 88.
--no-carry-forward-broker-cakeeps the bundle’s roots instead, and the report lists every broker that moved past them. - With no old database to read, the report says the live root state is unknown and names the brokers at risk. The Brokers page’s rotation alarm stays up until each of them reports again or you acknowledge it, and each acknowledged broker re-enrolls or is reinstalled.
- A lost key ring that no backup holds. The platform refuses to start, because its root’s key is gone.
docker compose run --rm wep-backup broker-ca recoverchanges nothing: it shows what the next start will do and prints a phrase. Run it again with--confirm <phrase>to record the request. The next start mints a new root, retires the lost one, ends any open rotation and replaces both broker enrollment keys. Every broker is then reinstalled from a freshly generated install command; re-enrolling does not work. - An ended root’s key leaves the database files. Since platform 26.11.501, after a root is retired or withdrawn, after a lost-key-ring recovery and after a restore, the platform rewrites its root table, so the ended root’s wrapped private key no longer remains in the database files.
- After any rotation step, do not roll back to an image older than 0.253.0: its restore would put the old roots back and strand the brokers that moved. The rotation itself is on brokers and detonation hosts.
Exit codes
docker compose run exits with the command’s own code, so a cron job or a script can act on it.
| Code | What it means |
|---|---|
| 0 | Done. A bundle was written, read back and recorded; a restore swapped in; a drill verified. The pre-upgrade one-shot also exits 0 when there was nothing to back up or the override was recorded. |
| 64 | The command line is wrong. From a restore also: the target already holds an installation and --replace was not given, or the named bundle is older than the newest one and --accept-older was not given. Nothing was done. |
| 65 | A bundle did not verify. A new bundle did not read back as written and was not committed; or a bundle to restore does not match the expected signer, misses a segment, or has no signer to expect. |
| 66 | The bundle was not found, or the backup folder cannot be read. |
| 69 | Something is in the way: the database did not answer, another backup or a restore holds the lock, or, for a restore, the platform is still running. Wait, or stop the platform and the scheduler, and run it again. |
| 70 | A step failed for another reason, such as a database tool or an unreadable key file. The log names the cause, and the scheduler retries it. |
| 73 | A folder or volume is refused or cannot be written, or the database volume has too little room for a restore. |
| 75 | The act happened, but its audit record could not be written. For the pre-upgrade override this stops the upgrade. |
| 77 | The key does not open the bundle: the wrong key or passphrase, or no key given for a bundle encrypted to a certificate. |
| 78 | The setup is refused: no recipient, an unusable certificate, a missing span signer key, a lost state volume, a database role or a PostgreSQL version that does not fit. The message names the setting or the file. |
| 86 | The database, or the bundle, holds migrations this image does not know: a newer version wrote it. Nothing was changed. |
| 87 | Installer files the bundle refers to are neither on the shelf nor in the store. |
| 88 | A check before the swap failed, or swapping in either root table would strand brokers. The live installation is untouched. From a drill: the bundle is recorded as not verified. |
| 89 | A restore is open: it stopped at a journalled step. Run the same restore again, or abandon it before its swap. |
| 93 | The bundle recorded no statement counts, because a version before 26.11.1400 took it. A restore stopped before it loaded anything; --accept-count-unknown <phrase> restores it anyway. From a drill: the bundle is recorded as not verified. |
| 94 | Some spans verify under no key the installation recorded: their signer key was lost before platform 0.245.0. A restore stopped at its checks; --accept-unverifiable <phrase> restores it anyway. From a drill: the bundle is recorded as not verified. |
broker-ca recover has its own codes: 0 when it previewed or recorded the request, 64 for a wrong command line, 65 when no recovery applies or the phrase is not the one it printed, 69 when the database could not be read or written, and 78 when broker management is not enabled. It does nothing on any code but 0. The platform’s own refusal of a database server older than PostgreSQL 18 is exit 90; see upgrades and rollback.
The statement journal: signed records off the box
Since platform 26.11.1700, Community Edition can copy every signed statement to a second disk or a NAS as it is written. Turn on the journal compose profile (COMPOSE_PROFILES=journal) and point WEP_JOURNAL_DIR at a folder on another disk. The wep-backup-journal relay then writes each signed record and signing-key change there within seconds, in batches signed with the backup signing key. It needs the backup recipient certificate, and it waits until the first backup has created the backup signing key. It refuses a folder that lost batches and another installation’s folder. Both settings are unset by default, so the journal is off until you turn it on. Since platform 26.11.2700, Community Edition shows the journal’s state on Settings › Storage, in the Recovery layers card, and Home raises a row when the journal stops reporting, stops writing or keeps failing. The card’s third layer, a standby, is not built and always reads Not set up.
Since 26.11.1800, restore --journal <folder> brings back the signed records written after its bundle. After loading the bundle, the restore checks the journal from the point the bundle recorded and imports every signed record, signing-key change and version statement written since, and its report says what came back, what did not, and why. A key the bundle did not hold, a record that conflicts with a stored one, or a per-user data erasure made after the bundle stops the restore until you run it again with the phrase it prints, and an erasure is applied again before the swap, so erased personal data does not come back. --replay-until stops the replay at an entry number or a time. With --journal, the drill replays into its scratch copy, prints what would come back, and fails when the journal lost the bundle’s point or nothing after it verifies.
On a dedicated instance
A dedicated instance runs in your own Azure subscription, and so do its backups.
Always on: Azure’s point-in-time restore. The instance’s five databases live on one Azure PostgreSQL flexible server, whose automated backups bring all five back to any point inside the retention window (backupRetentionDays, 14 days by default, 7 to 35). Azure states that the newest point you can restore to can be up to five minutes old. They stay in the instance’s region, with no geo-redundancy. The key ring and the installer files are kept with blob versioning and 30-day soft delete, and the vault’s keys with soft delete and purge protection. A point-in-time restore brings the databases back as they were; it runs none of the token and session resets a bundle restore runs.
Optional: the nightly bundle, since platform 0.247.0. It ships off (deployBackup), and turning it on needs a custom role your administrator creates, which can only read, stop and start the instance’s container app. The platform is stopped while the job dumps, for the length of the dump. A bundle holds:
- a dump of each of the five databases;
- a manifest signed by a non-exportable signing key in a separate backup vault, on which the platform’s own identity holds no role;
- the list of tables whose row-level security the dump had to release, so a restore forces exactly those again;
- references to the instance’s keys, each vault key, certificate and secret by versioned id and the key ring by blob version, instead of the keys themselves;
- no installer files: those stay in the instance’s storage, under versioning.
The dumps are encrypted since platform 0.253.0, to a dump key in that backup vault, in your subscription. It is an RSA-3072 key that cannot be exported, has no release policy and allows one operation, unwrapping. The backup job can read only its public half, so it can encrypt a dump and never open one. Only the restore identity, which only the instance’s restore job carries, may ask the vault to unwrap a segment’s key. That keeps a dump unreadable to someone who can read the backup storage and nothing more, and to any copy that leaves it. It does not stop anyone who can grant themselves the restore identity’s role or start the restore job, which includes our deploy identity through its Role Based Access Control Administrator role on the resource group. Nor does it stop anyone who can reach the live database, which holds the same rows. A bundle restores only while its key version exists. Bundles written before 0.253.0 have plain dumps.
You start a restore. The design gives Attestree no standing data access to the backups, though our deploy identity can grant itself the restore identity’s role, as above. Your operator starts the instance’s restore job, from a network that reaches its private endpoints, and we talk you through it. While the platform still serves, the job checks the bundle against the backup vault key’s fingerprint. It then stops the platform and logs a restore point; a point-in-time restore to that point undoes the whole restore. It replaces the five databases in place, migrates them forward, revokes every session and enrolment token, and carries the live broker CA roots forward. A plain start restores the newest bundle that verifies; for an older one, ask us first.
Since platform 26.11.2400 it also re-applies what was revoked after the snapshot, read from the live databases before it replaces them: device-key distrusts, span-key and signing-key revocations, broker certificate revocations, a latched emergency stop, and per-user erasures. --no-carry-forward does not apply on a dedicated instance, so nothing skips this. To undo a change made after the bundle, such as a mass distrust, restore the server to a point in time before that change instead; that undoes everything after it as well.
The report says that what changed is unknown, and those changes have to be made again by hand, in three cases: a live database cannot be read, the run takes over a restore that had already begun replacing the databases, or the live databases share none of the bundle’s platform signing keys or hold no audit record newer than the snapshot, as on a rebuilt server.
What it does not do yet: carry forward emergency-stop signer removals or device keys added after the snapshot (remove each such signer again by hand; an agent whose device key is newer than the bundle enrols again), copy installer files, or run --drill. A drill on a dedicated instance is a point-in-time restore to a throwaway server, checked by hand.
Where this stops
- No certificate, weak backups. Without a recipient certificate there are no scheduled backups, and a pre-upgrade bundle holds no keys and an unencrypted dump.
- One key opens everything. Lose the private key, or a passphrase-protected key’s passphrase, and the bundles encrypted to it stay closed.
- The drill is yours to run. It needs the private key, so nothing proves a bundle restores until you run it.
- Bundles stay on the host until you move them. The default folder is beside the compose file, on the database’s own disk.
- Signed statements after the bundle are gone, unless the journal is on. Agents delete a span once the server accepts it, and by default the platform publishes no signed statement anywhere else, so a restore without the statement journal loses every one written after the bundle. Spans are signed one by one with no chain, and nothing off the box records how far the log had reached, so the restored log gives no sign that any are missing.
- A restore is not an undo. Everything after the bundle is gone except what carry-forward re-applies. Everyone signs in again, keyed agents come back at 50 machines per tenant per day, and agents without a device key enrol again.
- Backups outlive retention. A retention prune and an erasure do not reach a bundle already written; a bundle keeps what it holds until the schedule, or you, remove it.
- A dedicated instance’s bundle is newer and narrower. It ships off and restores in place with the platform stopped. Its restore carries revocations forward with no switch to skip them, and leaves out emergency-stop signer removals and device keys added since. It copies no installer files and has no drill of its own.