Backups and restore
Configure encrypted backups outside your server and test recovery.
Overview
The worker creates a full database backup every night. It also creates a smaller backup of decisions and configuration every hour. You do not need to schedule these jobs.
You must configure storage outside the server. A local volume does not protect against server loss. Provider snapshots do not protect against account loss. An external, encrypted backup protects your data only if you can restore it.
Configure
Automatic backups
| Backup | Schedule | Contents | Local retention |
|---|---|---|---|
| Nightly | 03:00 UTC | The full database | The newest 14 |
| Hourly | 17 minutes past each hour | Decisions and configuration, including the items below | The newest 24 |
Hourly backups include merges, review decisions, tags, segments, notes and reports. They also include routing rules, sinks, connections, encrypted credentials, API keys and settings.
An hourly backup supplements the preceding nightly backup. It cannot restore the database alone. The nightly backup supplies activity and source data.
Encrypt and copy them off the machine
Create a key pair on another computer
Install age on your computer. Generate the keys there.
age-keygen -o backup-key.txtThe file contains the private key. The command prints the public key, which starts with
age1.Store the private key in your password manager.
Create a bucket
Create a bucket with an S3-compatible provider, such as Cloudflare R2, Backblaze B2, MinIO or Amazon S3. Give Datum credentials with read and write access to that bucket.
Datum does not create buckets.
Configure backup retention
Add a lifecycle rule to expire old backups. Use a 35-day retention period unless your requirements differ.
Datum never deletes objects from the bucket. The lifecycle rule handles expiry. It does not stop someone with the storage credentials from deleting or replacing objects.
Enable the provider’s object lock, retention lock or a policy that denies deletion. Follow the provider’s instructions for this protection.
Add the settings
Add the following settings to
deploy/.env.OCMGR_BACKUP_PUBKEY=age1… OCMGR_BACKUP_S3_URL=s3://my-bucket/ocmgr OCMGR_BACKUP_S3_ENDPOINT=https://<account-id>.r2.cloudflarestorage.com OCMGR_BACKUP_S3_REGION=auto AWS_ACCESS_KEY_ID=… AWS_SECRET_ACCESS_KEY=…Leave the endpoint unset for Amazon S3. Set
OCMGR_BACKUP_S3_REGIONto the bucket’s region, such aseu-west-2.Without that setting, Datum uses
AWS_REGION, thenAWS_DEFAULT_REGION, thenus-east-1. Datum does not look up the bucket’s region. A wrong region causes uploads to fail.Run
docker compose -f deploy/docker-compose.yml up -dto apply the settings.Check the backup
Create a backup. Run doctor to check its storage.
docker compose -f deploy/docker-compose.yml exec -T app ocmgr backup --json docker compose -f deploy/docker-compose.yml exec -T app ocmgr doctor --jsonDoctor’s
backup_targetcheck looks for a recent encrypted full backup recorded for the configured bucket and prefix. It checks that the dump and its manifest are still there and compares the dump size with the recorded size when available. If you change the destination, runocmgr backup --jsonto establish a backup there.
Basics
See when backups last ran
Inspect the job status from the operator terminal, with an admin API key, or through an admin hosted MCP connection.
ocmgr jobs status --json{ "name": "get_ops_status", "arguments": {} }curl "$OCMGR_URL/v1/ops" -H "Authorization: Bearer $OCMGR_API_KEY"backups.last reports the most recent full or decisions-only backup attempt. Its kind identifies the backup and its status shows whether it succeeded, failed or was skipped. backups.ageHours counts hours since the latest success of either kind. A successful hourly backup can therefore show a recent age after a nightly backup failed. Run ocmgr doctor --json and inspect backup_target to check the latest full backup at the configured destination.
When the default local directory is writable, the worker can write local dumps even before you configure encryption or external storage. Doctor reports backup_target: skipped until you set OCMGR_BACKUP_DIR, OCMGR_BACKUP_PUBKEY or OCMGR_BACKUP_S3_URL. Local dumps alone do not protect against losing the server.
Hosted backup status
The OCMGR team manages backups for hosted instances. These are Datum-created full and decisions-only database dumps, using the schedules above. The report covers the whole instance, not only your workspace. It does not inventory hosting-provider snapshots or point-in-time recovery.
encrypted: false means that Datum wrote the dump without age encryption. offMachine: true means Datum verified the dump and its manifest at the external destination. Local-only backups and uploads that failed verification show offMachine: false.
These values describe the dump itself; they do not describe provider disk encryption. A local dump under /data/backups is not evidence of off-site protection.
Ask the hosted operator to confirm external retention and recovery coverage when these flags are false. A successful dump does not prove recovery works; check backups.lastRestoreTest separately.
Prove a backup restores
ocmgr restore-test restores the newest backup into a temporary database. It compares row counts with the backup manifest. It checks workspace isolation and credential decryption. It then removes the temporary database.
Datum does not schedule restore tests on your instance because they require the private key. Run a restore test weekly from the checkout. Keep the private key outside the server between tests.
The test container must run as uid 1000, which owns the data volume. Local backup permissions allow only that user to read them.
Create a private directory for the key. Give uid 1000 access with the following commands.
mkdir -m 0700 recovery
cp backup-key.txt recovery/ && chmod 0400 recovery/backup-key.txt
sudo chown -R 1000:1000 recovery
Run the test as uid 1000.
docker run --rm --user 1000:1000 --network ocmgr_default \
--env-file deploy/.env -v ocmgr_data:/data \
-v "$PWD/recovery:/key:ro" \
ocmgr:local restore-test --privkey /key/backup-key.txt --json
The command returns a non-zero exit status if any check fails. --privkey accepts a file path, so the key stays out of shell history.
To test recovery through the latest hourly archive, name the preceding nightly dump and add --decisions <hourly-archive> to the restore-test command. The test restores the nightly dump first and then applies those decisions.
Remove the temporary keys afterwards with sudo rm -rf recovery backup-key.txt.
Restore for real
Restore into a new, empty database on the same Postgres server. Never restore over the live database.
These commands use the restore test’s container configuration. They require uid 1000 and the private recovery directory described above.
The commands assume the defaults: database user ocmgr (POSTGRES_USER) and Compose project ocmgr, which names the ocmgr_default network and the ocmgr_data volume. If you changed either, replace ocmgr in those places. docker network ls and docker volume ls show the names on your machine.
Prepare an empty database
Stop the app. Create the replacement database.
docker compose -f deploy/docker-compose.yml stop app docker compose -f deploy/docker-compose.yml exec db createdb -U ocmgr ocmgr_restoredRestore the dump
Specify the backup’s
s3://address or its path under/data/backups. Supply the new database URL with the password fromdeploy/.env.docker run --rm --user 1000:1000 --network ocmgr_default \ --env-file deploy/.env -v ocmgr_data:/data \ -v "$PWD/recovery:/key:ro" \ ocmgr:local restore <dump> \ --into "postgres://ocmgr:<password>@db:5432/ocmgr_restored" \ --privkey /key/backup-key.txt --jsonocmgr restorerejects a database that already contains tables.Apply the latest hourly decisions
Keep the app stopped. If you have an hourly archive newer than the nightly dump you restored, apply the newest one now. Use an archive from the same instance and backup sequence.
docker run --rm --user 1000:1000 --network ocmgr_default \ --env-file deploy/.env -v ocmgr_data:/data \ -v "$PWD/recovery:/key:ro" \ ocmgr:local restore <hourly-archive> --decisions \ --into "postgres://ocmgr:<password>@db:5432/ocmgr_restored" \ --privkey /key/backup-key.txt --jsonThe command refuses a database that has changes newer than the archive. Follow its returned
nextcommands to rebuild derived profiles, organisations and segments once per workspace, against the restored database.Reconcile access and repeat later erasures
Keep the restored database isolated and its workers stopped. Reconcile user removals, role reductions, cancelled invitations, agent disconnects and revoked credentials against the access records since each snapshot. Follow the access recovery procedure.
A restore also includes people whose erasures occurred after the nightly snapshot. Reconcile those requests against the restored identities, reapply the erasures and verify source suppression before reopening ingestion. Follow the erasure recovery procedure.
Select the restored database
Change the database name in
DATABASE_URLtoocmgr_restoredindeploy/.env. Start the app withdocker compose -f deploy/docker-compose.yml up -d.Check the restored instance
Run
ocmgr doctor --json. Resolve any failed checks. Runocmgr stats --json. Check that the expected members appear.
Run ocmgr doctor --verify-restore <database-url> --manifest <file> --json to check the database before switching. Specify the .manifest.json file beside the backup.
The command checks migrations, row counts, workspace isolation and stored credentials.
Preview backup or restore work
backup --dry-run --json reports its destination, encryption and retention without writing a dump. restore <dump> --into <database-url> --dry-run --json validates the archive and destination without restoring data. restore-test <dump> --dry-run --json inspects the archive without creating a temporary database. Archive inspection may download the archive. restore --dry-run requires the same decryption key as a restore; restore-test --dry-run only inspects the archive and manifest.
FAQ
Do I need the bucket if my host takes snapshots?
Yes. Snapshots share the database’s provider and account. Losing that account can remove both copies.
Can I keep backups only on the machine?
Yes. Datum still creates and retains local backups. They can help recover from a failed migration, but they cannot protect against server loss. Doctor reports their storage location.
Why does doctor fail restore_ready when I set OCMGR_BACKUP_PRIVKEY?
The server would hold both the encrypted backups and the key that decrypts them. Leave that variable empty on the server. Pass the private key file only when you restore.