Backup Database
db_backupCreates a full SQL dump of a PostgreSQL database using pg_dump, saving schema and data to a timestamped file in the configured backup directory. Use before migrations or for periodic backups.
Instructions
Creates a full SQL dump of the database using pg_dump and saves it to the configured backup directory (default: ./backups). The backup includes the full schema and data. When the local pg_dump binary is not available and DOCKER_CONTAINER is set, this tool falls back to running pg_dump inside the specified Docker container.
When to use:
Before running risky migrations or bulk operations
Periodic backups as part of maintenance routines
When the user asks to back up or export the database
Parameter guidance:
label: optional label for the backup filename (e.g., "pre-migration"). The final filename includes a timestamp: backups/db_backup_pre-migration_2026-09-01T120000.sql
confirmed: set to true to confirm the backup operation
Behavioral notes:
Requires pg_dump to be available either locally or via Docker.
The backup file is a plain SQL dump, not a binary format.
Large databases may take significant time and disk space.
This tool is idempotent — running it multiple times creates separate backup files.
The backup directory is created automatically if it does not exist.
Returns: path to the created backup file and its size.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| label | No | Optional label for the backup filename | |
| database | No | Name of the database to query (from pgautopilot.json). Omit to use the current default database. | |
| confirmed | No | Explicit user confirmation required to run a backup |