|kolaente 270e62e142||1 month ago|
|.drone.yml||1 year ago|
|.gitignore||1 year ago|
|Dockerfile||1 year ago|
|LICENSE||1 year ago|
|README.md||6 months ago|
|cleanup.go||1 year ago|
|client.go||1 year ago|
|config.go||1 year ago|
|dump.go||6 months ago|
|dump_mysql.go||1 month ago|
|dump_mysql_test.go||1 year ago|
|dump_postgres.go||6 months ago|
|dump_test.go||1 year ago|
|go.mod||1 year ago|
|go.sum||1 year ago|
|helper.go||1 year ago|
|main.go||1 year ago|
|save.go||1 year ago|
|store.go||1 year ago|
Zero-Fuss Docker Database Backup
A simple tool to create backup of all databases on a host. Supports postgres and mysql/mariadb.
Successor to this script.
Simply point it at your docker socket, mount a backup volume and be done:
docker run -v $PWD/backups:/backups -v /var/run/docker.sock:/var/run/docker.sock kolaente/db-backup
The tool will find all database containers running an official
postgres image and
create backups of them periodically. It will also discover new containers
as they are started and won't try to back up containers which have gone away.
When running, all backups for the current run are time-stamped into a sub folder of the backup directory (see below).
To make the backup tool discover other non-offical containers as well you can add the label
any container with a value of
postgres to treat it as a mysql or postgres container.
If you're running docker-compose, you can use a setup similar to the following compose file to run the backup:
version: '2' services: backup: image: kolaente/db-backup restart: unless-stopped volumes: - ./backups:/backups - /etc/localtime:/etc/localtime:ro - /var/run/docker.sock:/var/run/docker.sock
All config is done with environment variables.
Where all backup files will be stored.
The cron schedule at which the backup job runs, using the common unix cron syntax.
Check out crontab.dev for a nice explanation of the schedule.
0 */6 * * * (every 6 hours)
How many backups to keep. If more backups are stored in the backup folder, the oldest one will be removed until there are only as many as this config variable.
Building from source
This project uses go modules, so you'll need at least go 1.11 to compile it.
go build .
to build the binary.