This page explains the mental model behind DBdock. Reading it once will make every other page easier to follow.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.
Backup anatomy
A DBdock backup is always one file per backup. The filename encodes when it was taken:dbdock list, dbdock restore, and retention policies know what’s available.
The pipeline
Every backup flows through the same stages:pg_dump and the destination. This is why you can:
- Skip compression for tiny DBs where speed matters more than size
- Skip encryption on local-only backups if you manage the disk
- Change storage providers without re-dumping your database
Backup formats
DBdock supports all four PostgreSQL formats frompg_dump:
| Format | Extension | When to use |
|---|---|---|
custom (default) | .sql | Best for most cases — binary, compressed by pg_dump, selective restore supported |
plain | .sql | Human-readable SQL, works with psql directly |
directory | .dir | Parallel dump/restore for very large DBs |
tar | .tar | Tar archive of the directory format |
dbdock.config.json:
Compression
DBdock uses zstd for compression. zstd is fast and compresses roughly as well as gzip at higher levels.- Level 0 — no compression
- Level 6 (default) — balanced
- Level 11 — maximum compression, slower
pg_dump, so it works regardless of backup format.
Encryption
DBdock encrypts with AES-256-GCM. The key is derived fromDBDOCK_ENCRYPTION_SECRET using PBKDF2 with 100,000 iterations (configurable).
- Encryption is applied after compression, so encrypted backups are also compressed.
- The IV is generated fresh per backup and stored in the file header alongside the ciphertext.
- Losing the secret = losing the ability to restore. Store it somewhere other than the backup destination.
Storage adapters
DBdock ships adapters for four storage backends. They all implement the same interface —put, get, list, delete — so swapping providers never requires changing how you use the CLI.
Local
Disk-based storage.
AWS S3
S3 and any S3-compatible object store.
Cloudflare R2
Zero-egress object storage.
Cloudinary
Media-focused storage service.
Retention
Without cleanup, backups accumulate. DBdock applies a retention policy with three knobs:maxBackups— cap the total countmaxAgeDays— delete backups older than N daysminBackups— never delete below this count, no matter what
minBackups is the safety net — even if every other rule says “delete,” DBdock will refuse to go below it. See Retention strategies for recommended settings.
The config file
dbdock.config.json holds non-sensitive configuration and is safe to commit. It has four top-level sections:
Programmatic use
Everything the CLI does, you can do from code. DBdock exports a small NestJS-based module that exposesBackupService, StorageService, and CryptoService:

