BackupPilot screenshot
BackupPilot is a cross-platform Python command-line utility for backing up and restoring multiple databases with pluggable storage backends (local filesystem, AWS S3, Google Cloud Storage, Azure Blob Storage), compression, and optional notifications.
- Multiple databases: MySQL, PostgreSQL, MongoDB, SQLite (extensible to others).
- Backup types: Full only (incremental and differential planned for a future release).
- Storage options: Local filesystem, AWS S3, Google Cloud Storage, Azure Blob Storage.
- Compression: Gzip by default, with an extensible compression interface.
- Encryption: Optional at-rest encryption for backups; use
encryption: none(default) orencryption: fernetwith the key supplied via theBACKUP_PILOT_ENCRYPTION_KEYenvironment variable (base64-encoded Fernet key). - Backup rotation: Optional retention per profile (
retention_countand/orretention_days); runbackup-pilot rotateto delete old backups. - Logging: Config-driven log level, optional file output, and JSON format (see
loggingin config). - Notifications: Slack and email notifiers with error handling so backup/restore never fail due to notification delivery.
- Restore operations: Restore from backup artifacts, with selective restore where supported.
- Backup history: Per-config backup history tracking with a
list-backupscommand showing backup metadata.
git clone https://github.com/rostam-sodagari/backup-pilot.git
cd backup-pilot
pip install .This will install the backup-pilot executable.
Show CLI help:
backup-pilot --helpCreate a backup_pilot.yaml file in your working directory (or use one of the example configs under examples/):
databases:
local_mysql:
type: mysql
host: localhost
port: 3306
username: root
password: example
database: app_db
storage:
local_fs:
type: local
options:
root_dir: ./backups
backups:
daily_mysql_full:
database: local_mysql
storage: local_fs
backup_type: full
compression: gzip
# encryption: none # default; use "fernet" and set BACKUP_PILOT_ENCRYPTION_KEY for encrypted backups
# retention_count: 7 # keep at most 7 backups per profile
# retention_days: 30 # delete backups older than 30 days
# logging:
# level: INFO
# file: /var/log/backup_pilot.log
# json: false
notifications:
slack:
webhook_url: "https://hooks.slack.com/services/XXX/YYY/ZZZ"
# email (optional; from, to, smtp_host required):
# smtp_host: smtp.example.com
# smtp_port: 587
# username: "${SMTP_USERNAME}"
# password: "${SMTP_PASSWORD}"
# from: backup-pilot@example.com
# to: ops@example.comRun a backup using the profile:
backup-pilot backup --profile daily_mysql_full --config-file backup_pilot.yamlWhen running backup-pilot directly on your host, BackupPilot will automatically
load environment variables from a .env file in the current working directory
if it exists. OS-level environment variables always take precedence.
To get started:
- Copy
.env.exampleto.env. - Fill in values such as
BACKUP_PILOT_ENCRYPTION_KEY, cloud storage credentials, and notification settings. - Run your backup command:
backup-pilot backup --profile daily_mysql_full --config-file backup_pilot.yamlEach successful backup is recorded in a history file that lives next to your config file:
- For
backup_pilot.yamlthe history file isbackup_pilot.history.jsonl. - Each line is a JSON record containing the backup ID, profile, database type/name, storage location, timestamps, backup type, and (where available) size in bytes.
You can list recorded backups:
backup-pilot list-backups --config-file backup_pilot.yamlFilter by profile and limit the number of results:
backup-pilot list-backups --config-file backup_pilot.yaml --profile daily_mysql_full --limit 10Restore from a backup:
backup-pilot restore --profile daily_mysql_full --backup-id 20250101010101 --config-file backup_pilot.yamlList configured profiles:
backup-pilot list-configs --config-file backup_pilot.yamlTest a database connection:
backup-pilot test-connection --db-profile local_mysql --config-file backup_pilot.yamlRun retention (rotate old backups according to retention_count / retention_days):
backup-pilot rotate --config-file backup_pilot.yaml
backup-pilot rotate --config-file backup_pilot.yaml --profile daily_mysql_fullThe CLI currently exposes the following top-level commands:
backup-pilot backupbackup-pilot restorebackup-pilot rotatebackup-pilot test-connectionbackup-pilot list-configsbackup-pilot list-backupsbackup-pilot wizard run(interactive configuration and optional execution)
You can use the wizard to interactively create or update a configuration and optionally run a backup immediately:
backup-pilot wizard run --config-file backup_pilot.yamlThe wizard will prompt you for:
- Database type (MySQL/MariaDB, PostgreSQL, MongoDB, SQLite)
- Connection details (host, port, username, password, database name)
- Storage profile (local path)
- Backup profile name and backup type (full only)
At the end, it saves the configuration and, by default, runs the backup using the new profile.
Incremental and differential backups are planned for a future release. Currently only full backups are supported.
When you enable rotation using retention_count and/or retention_days, BackupPilot applies the policy per backup profile. Rotation deletes old backup artifacts from the configured storage backend and rewrites the history file to keep only the retained records.
Build the image:
docker build -t backup-pilot .Run a backup (mount config and backup directory; set env vars for credentials/keys as needed):
docker run --rm -v /path/to/backup_pilot.yaml:/config/backup_pilot.yaml -v /path/to/backups:/backups backup-pilot backup --profile daily_mysql_full --config-file /config/backup_pilot.yamlUse environment variables for secrets (e.g. BACKUP_PILOT_ENCRYPTION_KEY, AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY for S3, or your cloud provider’s preferred vars).
The Docker image includes the following OS-level database client tools:
- MySQL/MariaDB:
mysql,mysqldump - PostgreSQL:
psql,pg_dump(viapostgresql-client) - MongoDB:
mongosh,mongodump,mongorestore
If you run BackupPilot outside Docker, ensure these tools are installed on your system and available on PATH.
GitHub Actions workflow (.github/workflows/ci.yml) runs on push and pull requests: tests (Python 3.10–3.12), Ruff and Black lint, and package build.
- Basic local backup config:
examples/config-basic.yaml - AWS S3 backup config:
examples/config-aws.yaml - Google Cloud Storage backup config:
examples/config-gcp.yaml - Azure Blob Storage backup config:
examples/config-azure.yaml - Cron script example:
examples/cron/backup-mysql-daily
These examples are starting points; you should adapt hostnames, credentials, buckets/containers, and schedule to your environment.