You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kolaente bd72e06825
continuous-integration/drone/push Build is passing Details
feat: print a little message when the service starts
5 days ago
.drone.yml feat: add drone config 2 years ago
.gitignore Add postgres dumper 2 years ago
Dockerfile fix: add ca root certificates 5 days ago
LICENSE chore: add license 2 years ago feat: add completion webhook url 5 days ago
cleanup.go feat: cleanup old backups 2 years ago
client.go Add methods to get containers 2 years ago
config.go fix: don't create backup path on startup 5 days ago
dump.go feat: add support for labels to discover additional containers 10 months ago
dump_mysql.go feat(mysql): dump everything 5 months ago
dump_mysql_test.go fix: test 5 days ago
dump_postgres.go fix: make sure to dump everything from postgres databases 10 months ago
dump_test.go Add test for determining the container dumper type 2 years ago
go.mod feat: replace interval with a proper cron schedule 1 year ago
go.sum feat: replace interval with a proper cron schedule 1 year ago
helper.go Add dump helpers 2 years ago
main.go feat: print a little message when the service starts 5 days ago
save.go feat: restructure writing to the file 2 years ago
store.go feat: remove old containers 2 years ago
webhook.go feat: add completion webhook url 5 days ago

Zero-Fuss Docker Database Backup

Build Status

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 mysql, mariadb or 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).

Using labels

To make the backup tool discover other non-offical containers as well you can add the label de.kolaente.db-backup to any container with a value of mysql or postgres to treat it as a mysql or postgres container.

Docker Compose

If you're running docker-compose, you can use a setup similar to the following compose file to run the backup:

version: '2'
    image: kolaente/db-backup
    restart: unless-stopped
      - ./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.

Default: /backups


The cron schedule at which the backup job runs, using the common unix cron syntax.

Check out for a nice explanation of the schedule.

Default: 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.

Default: 12


If provided, the tool will do an empty GET request to this URL to indicate it successfully completed the backup job. You can use this with other tools to monitor if backups are completed as they should.

Building from source

This project uses go modules, so you'll need at least go 1.11 to compile it.

Simply run

go build .

to build the binary.