Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.dbdock.xyz/llms.txt

Use this file to discover all available pages before exploring further.

npx dbdock backup [options]
Runs pg_dump, optionally compresses and encrypts the output, and streams it directly to your configured storage provider. You’ll see real-time progress:
████████████████████ | 100% | 45.23/100 MB | Speed: 12.50 MB/s | ETA: 0s | Uploading to S3
✔ Backup completed successfully

Options

OptionDescription
--encryptForce encryption on (overrides config)
--no-encryptForce encryption off (overrides config)
--compressForce compression on (overrides config)
--no-compressForce compression off (overrides config)
--encryption-key <key>Use a specific 64-char hex key for this backup
--compression-level <1-11>zstd compression level (default 6)

Examples

Standard backup

Uses everything from your config file:
npx dbdock backup

Force maximum compression

npx dbdock backup --compress --compression-level 11
Useful for archival backups where you’ll keep them for months.

Fast backup, no compression

npx dbdock backup --no-compress
When your storage is cheap and restore speed matters more than size.

One-off with explicit encryption key

npx dbdock backup --encrypt --encryption-key "$(cat ~/.keys/dbdock.key)"
Overrides DBDOCK_ENCRYPTION_SECRET just for this run.

Backup formats

The format comes from dbdock.config.json:
{
  "backup": { "format": "custom" }
}
FormatExtensionNotes
custom (default).sqlBinary, pg_dump’s native compression, selective restore
plain.sqlHuman-readable SQL, works with psql directly
directory.dirParallel dump support for huge DBs
tar.tarTar archive of directory format
See Concepts → backup formats for when to pick which.

What happens under the hood

  1. Connect — validates database credentials
  2. Dump — runs pg_dump with your configured format
  3. Compress (if enabled) — zstd at configured level
  4. Encrypt (if enabled) — AES-256-GCM with key derived from secret
  5. Upload — streams to your storage provider, no temp files
  6. Record metadata — size, duration, flags, storage key
  7. Send alerts (if configured) — Slack/email
  8. Retention (if runAfterBackup: true) — cleanup old backups

After the backup

npx dbdock list      # See it in the list
npx dbdock restore   # Restore to verify

Generating an encryption key

node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
Store the output in .env as DBDOCK_ENCRYPTION_SECRET. See Security for key management.