Skip to main content

init

Initialize DBdocks in your project.
npx dbdock init
This interactive wizard creates the dbdock.config.json file. It asks for:
  • Database connection details
  • Storage provider configuration
  • Encryption and compression preferences
  • Email and Slack alerts (optional)

backup

Create a new database backup.
npx dbdock backup [options]

Options

OptionDescription
--encrypt / --no-encryptToggle encryption (overrides config)
--compress / --no-compressToggle compression (overrides config)
--encryption-key <key>Specify a 64-char hex encryption key
--compression-level <1-11>Set compression level (default: 6)

Example

npx dbdock backup --encrypt --compress --compression-level 9

Backup Formats

DBDock supports multiple PostgreSQL backup formats:
  • custom (default) - PostgreSQL custom binary format (.sql)
  • plain - Plain SQL text format (.sql)
  • directory - Directory format (.dir)
  • tar - Tar archive format (.tar)

Generate Encryption Key

Generate a secure 64-character hexadecimal encryption key:
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
The key must be exactly 64 hexadecimal characters (0-9, a-f, A-F).

restore

Restore a database from a backup.
npx dbdock restore
This command launches an interactive interface to select a backup. It supports smart filtering for large numbers of backups. Smart filtering (auto-enabled for 20+ backups):
  • Show recent (last 10)
  • Date range (24h, 7d, 30d, 90d, custom)
  • Search by keyword/ID
Migration Support: You can choose to restore to a New Database Instance during the restore process. This is perfect for migrating data between servers (e.g., from staging to production or local to cloud).
  1. Run npx dbdock restore
  2. Select a backup
  3. Choose “New Database Instance (Migrate)”
  4. Enter connection details for the target database
Shows database stats and requires confirmation before restore.

list

List available backups.
npx dbdock list [options]

Options

OptionDescription
--recent <number>Show the last N backups
--search <keyword>Search backups by keyword or ID
--days <number>Show backups from the last N days

Examples

npx dbdock list --recent 10
npx dbdock list --search "pre-deploy"
Auto-filtering for 50+ backups with interactive prompts.

delete

Delete backups.
npx dbdock delete [options]

Options

OptionDescription
--key <id>Delete a specific backup by ID
--allDelete all backups (requires confirmation)

cleanup

Manually trigger the retention policy cleanup.
npx dbdock cleanup [options]

Options

OptionDescription
--dry-runPreview what would be deleted without taking action
--forceSkip confirmation prompt

schedule

Manage automated backup schedules.
dbdock schedule
This interactive command allows you to:
  • View current schedules with status
  • Add new schedules (using cron expressions or presets)
  • Remove or toggle (enable/disable) schedules
  • Saves to dbdock.config.json

Schedule Presets

  • Every hour: 0 * * * *
  • Every day at midnight: 0 0 * * *
  • Every day at 2 AM: 0 2 * * *
  • Every week (Sunday): 0 0 * * 0
  • Every month (1st): 0 0 1 * *
  • Custom cron expression
Important: Schedules only execute when DBDock is integrated into your Node.js application (see Programmatic Usage). The CLI is for configuration only.

status

View all schedules and service status at a glance.
dbdock status

Example Output

📅 Scheduled Backups:

┌─────┬──────────────┬─────────────────┬──────────┐
│  #  │ Name         │ Cron Expression │ Status   │
├─────┼──────────────┼─────────────────┼──────────┤
│   1 │ daily        │ 0 * * * *       │ ✓ Active │
│   2 │ weekly       │ 0 0 * * 0       │ ✗ Paused │
└─────┴──────────────┴─────────────────┴──────────┘

Total: 2 schedule(s) - 1 active, 1 paused

🚀 Service Status:

🟢 Running (PM2)
  PID: 12345
  Uptime: 2d 5h
  Memory: 45.23 MB

test

Validate your configuration.
npx dbdock test
Checks database connection, storage access, and email configuration.