Skip to main content

Basic usage

Options

All options default to the values in dbdock.config.json. Pass only the ones you want to override.

Result shape

Examples

Schema-only backup

Captures DDL (tables, indexes, constraints) but not data. Tiny files — good for tracking schema evolution.

Data-only backup

Captures rows without DDL. Useful when you’re restoring into a database that already has the schema.

Plain SQL backup

Human-readable SQL you can grep, inspect, or feed to psql. Usually much larger than custom format.

Maximum compression for archival

Slower to create but up to 20-30% smaller than the default level 6. Worth it for long-term retention.

One-off unencrypted backup

Overrides the config’s encryption setting for this single backup.

Error handling

Errors from createBackup are standard Error instances with a .code property for structured handling.

Alerts are automatic

If alerts are configured in dbdock.config.json, they fire after createBackup — success or failure. You don’t need to do anything extra. See SDK → alerts if you want to send alerts manually.

Performance tips

Large databases

Stream the output — which DBDock does by default — so you never buffer the whole dump. Avoid calling createBackup concurrently against the same database; PostgreSQL will serialize the dumps anyway and you’ll waste resources. Run the backup process on a machine near the database, not near your storage. The dump is usually 2-10x larger than the compressed/encrypted output, so it’s cheaper to dump locally and upload than to dump across the internet.

Monitoring

Measure result.metadata.duration and alert if it drifts. Backup duration is a good proxy for database health.

See also

Listing backups

Query the backup history.

Scheduling

Run on a schedule.

Alerts

Programmatic alerts.