Backup and restore
Fresh install and matching key
Dopbase 0.1.0 accepts backups created by 0.1.0 only. A restore also needs the matching source master.key when moving between servers. Test recovery before relying on it for production data.
Dopbase includes a native, full-system backup and disaster recovery engine. Unlike per-environment .env export and import, a backup captures the complete server state in an encrypted archive: all projects, environments, secret keys and version histories, runner tokens, and administrator accounts.
Backups are packaged in authenticated, encrypted containers with the .dop file extension and protected by your server's 32-byte master encryption key.
Architecture & security model
The .dop container
A .dop backup file is a cryptographically protected container structured as follows:
- Inner Archive: A standard ZIP archive containing:
dopbase.db: A consistent SQLite snapshot produced using SQLite's online vacuum/backup API.manifest.json: Metadata including schema version, creation timestamp, Dopbase server version, and record counts.
- Authenticated Encryption (AEAD): The entire archive is encrypted using XChaCha20-Poly1305 with a fresh, cryptographically secure 24-byte nonce and a 16-byte authentication tag.
- Envelope Header: The file starts with magic bytes
DOPBASE_BK1\0, followed by the 24-byte nonce and the authenticated ciphertext.
+-----------------------------------------------------------------------+
| Magic: "DOPBASE_BK1\0" | Nonce: 24 bytes |
+-----------------------------------------------------------------------+
| Encrypted Payload: Zip (dopbase.db + manifest.json) |
+-----------------------------------------------------------------------+
| Poly1305 Authentication Tag: 16 bytes |
+-----------------------------------------------------------------------+Because the outer container is fully authenticated, tampering with or modifying any byte causes decryption to fail immediately before any database or file system changes occur.
Root-of-trust: The master key
Every Dopbase instance is initialized with a high-entropy 256-bit (32-byte) root encryption key saved to disk at:
~/.dopbase/master.keyThis master key serves two critical roles:
- It derives the encryption keys used to encrypt project secret values inside the SQLite database.
- It encrypts and authenticates
.dopbackup containers.
IMPORTANT
Because secret values stored inside dopbase.db are encrypted using keys derived from your instance's master key, a .dop backup file cannot be decrypted or restored onto a new server without that original master key.
Disaster recovery scenarios
There are two primary recovery scenarios:
Scenario 1: Same-server recovery
You are rolling back or restoring a snapshot on an existing, operational Dopbase server that is still using its original master.key:
- Required Inputs: The
.dopbackup file only. - Workflow: Dopbase uses the running server's active master key to authenticate and decrypt the
.dopfile, then replaces database tables atomically.
Scenario 2: Cross-server migration / Fresh instance rebuild
You are spinning up a new server, rebuilding after total hardware loss, or migrating to a new machine:
When you start a fresh Dopbase instance (dopbase serve), it generates a new, unique master key and an empty database. If you attempt to restore your .dop backup using the new server's temporary master key, decryption fails because the cryptographic keys do not match.
To solve this smoothly and securely, Dopbase provides Dual-Input Restoration with Automatic Re-Keying:
- Required Inputs:
- The
.dopbackup archive. - The source server's master key (either as the
master.keyfile or a 64-character hex string).
- The
- Automatic Re-Keying (Zero Key Collisions):
- Dopbase uses the provided source master key to decrypt and verify the
.doparchive. - Dopbase automatically re-keys the snapshot's database to the target server's existing master key (unwrapping and re-encrypting all secret keys and verification metadata).
- The target server's existing
master.keyfile on disk remains completely untouched, preserving machine key isolation. - The uploaded source key is discarded immediately from memory after decryption and re-keying.
- The re-keyed backup is stored on the server so that subsequent restores can run directly using the server's master key without requiring any key input.
- Dopbase uses the provided source master key to decrypt and verify the
Live server requirement
IMPORTANT
Both dopbase backup and dopbase restore require an active, reachable server (server_status: connected (live)).
Before initiating a backup or restore, Dopbase connects to the server to verify health, ensure cryptographic services are ready, and confirm that the instance is in a safe operational state. If the server is stopped or disconnected, the CLI halts and guides you to start the server:
dopbase serve --backgroundCommand line (CLI) workflows
1. Creating a backup
To create a system snapshot on your active server:
# Timestamped backup saved on the server (~/.dopbase/backups/)
dopbase backupTo assign a custom name prefix and save a local copy to your current directory:
dopbase backup pre-v2-deploy --output ./pre-v2-deploy.dopCLI Output:
Connecting to server at http://localhost:8840...
Server status: connected (live)
Creating snapshot "pre-v2-deploy"...
✓ Server database snapshotted
✓ Encrypted archive generated (142.8 KB)
✓ Stored on server: pre-v2-deploy_20260905_120000.dop
Downloading backup copy to ./pre-v2-deploy.dop...
✓ Download complete: ./pre-v2-deploy.dop (142.8 KB)
NOTICE: This backup is encrypted with this server's master key (~/.dopbase/master.key).
To restore on a new or different server, the master key will be required.2. Restoring on the same server
When restoring on the same machine that created the backup:
dopbase restore ./pre-v2-deploy.dopThe CLI prompts for confirmation before overwriting data:
Connecting to server at http://localhost:8840...
Server status: connected (live)
File: ./pre-v2-deploy.dop (142.8 KB)
WARNING: Restoring will overwrite all current projects, environments, and secrets
on http://localhost:8840 with the contents of this snapshot.
Existing administrator sessions will remain valid.
Proceed with restoring from the backup? [y/N] y
Uploading backup archive...
✓ Archive uploaded and verified
Restoring database tables...
✓ Tables replaced and migrations applied
✓ System restored successfully from "pre-v2-deploy_20260905_120000.dop"Pass --yes to skip the destructive confirmation prompt. Initialized restores still require an interactive administrator password confirmation:
dopbase restore ./pre-v2-deploy.dop --yes3. Restoring on a new server (Cross-Server Migration)
When restoring onto a newly installed or different Dopbase server, supply the original master key using the -k, --key option:
# Using the master.key file from the source server (and the target setup token on first run)
dopbase restore ./pre-v2-deploy.dop --key /path/to/source/master.key --setup-token dbs_...
# Or using the 64-character hex string
dopbase restore ./pre-v2-deploy.dop --key 4a2f8b9c01234567... --setup-token dbs_...Dopbase verifies and decrypts the backup against the provided key, automatically re-keys the database to the new server's existing master key, and restores the database tables without modifying the target server's ~/.dopbase/master.key file.
Admin UI workflows
The Dopbase Admin UI provides point-and-click management for backups and disaster recovery.
Downloading your master key
You should store a secure copy of your instance's master key in your team's password manager or cold storage vault.
- Navigate to Backups in the top navigation bar.
- Click Download Master Key in the upper-right actions toolbar.
- If your administrator session requires re-authentication, enter your password to confirm.
- Your browser downloads
master.key(a 32-byte binary file).
Restoring on first-run setup
When setting up a fresh Dopbase instance for the first time, navigate to the Web UI at http://localhost:8840:
- On the welcome screen, switch to the Restore from Backup tab.
- Enter the one-time setup token printed by the target server.
- Select your
.dopbackup file. - Under Source Master Key, upload the
master.keyfile from your previous server (or paste its 64-character hex key). - Click Restore System. Dopbase re-keys all secrets to the new server's master key.
- Once complete, you are redirected to the login screen where you can immediately sign in with your restored administrator credentials.
Backups dashboard
From Admin UI > Backups, administrators can:
- Create snapshots: Click New backup to take a consistent snapshot at any time.
- Download snapshots: Click the download icon next to any backup in the list.
- Upload snapshots: Click Upload backup to add a previously taken
.dopfile. If the file is from another server, provide its master key in the upload dialog. Dopbase will safely re-key the snapshot using this server's master key so it can be restored anytime. - Restore snapshots: Click Restore next to any snapshot in the table, review the warning, type
RESTORE, and confirm.
Best practices for disaster recovery
- Back up your master key separately: Never store your
master.keyin the same directory or archive as your.dopbackup files. Store your master key in an encrypted password manager (1Password, Bitwarden) or hardware security module (HSM). - Automate off-site replication: Use
dopbase backup [name] --output /mnt/secure-backups/daily.dopin an automated cron job or systemd timer, and replicate the.dopfile to offsite S3 or cloud storage. - Periodically practice recovery drills: Spin up a disposable container or local test instance and execute
dopbase restore <file.dop> --key <key>to ensure your team is familiar with the disaster recovery procedure.