Public | Automated Build

Last pushed: a day ago
Short Description
backup all DBs in a mysql server
Full Description

Regular backup an DB found in the mysql linked as "mysql" to the voloume /var/dbdumps.

Setup

You have to:

  • run the container `dsteinkopf/backup-all-mysql``
  • create a link called mysql to you db to be backed up.
  • Create a volume called /var/dbdumps.

Envorionment

  • Interval may be set via environment BACKUP_INTERVAL (in seconds).
  • Use BACKUP_FIRSTDELAY to delay the very first backup to be done by n seconds. The idea behind this is to prevent existing backups to be overwritten in case of problems. So you can manually kill everything an try again within this delay.
  • MYSQLDUMP_ADD_OPTS (default = ""): More options to be added to mysqldump.
  • MYSQL_CONNECTION_PARAMS (default = ""): More mysql option to add to any mysql command (incl. mysqldump)
  • MYSQL_HOST (default = "mysql"): Hostname (or IP) of mysql database.
  • MYSQL_USER (default = "root"): Username to connect to mysql database.

Monitoring

For an easy monitoring of successful backup an error file /var/dbdumps/errorslastrun.log is created (in volume /var/dbddumps. This file contains errors if there were any - it is empty if everything was ok.

So to monitor correct backup you should

  • check that errorslastrun.log is empty.
  • chat that errorslastrun.log is touched (modification date changed) regularly (see env BACKUP_INTERVAL).

Usage example

In docker-compose.yml:

mysql-backup:

  image: dsteinkopf/backup-all-mysql:latest
  environment:
    - BACKUP_INTERVAL=20000
    - BACKUP_FIRSTDELAY=3600
  links:
    - mysql
  restart: always
  volumes:
    - /opt/dockervolumes/wordpress/mysql-backup:/var/dbdumps
    - /etc/localtime:/etc/localtime
    - /etc/timezone:/etc/timezone

-> for example found in my Zabbix Setup (German language)

Docker Pull Command
Owner
dsteinkopf
Source Repository

Comments (4)
galianos
4 months ago

I need to keep the old backup files. Is it possible to set an individual name for each backup like "time-database.sql"?

dsteinkopf
8 months ago

@gfournel: No. I'd like to keep everything "orthogonal". So to backaup more than one server - use more than one backup container.

gfournel
9 months ago

Hi,
Do you plan to add the possibility to backup several MySQL Container, and not juste one ?

dfisenko
a year ago

Please tell me, how to run your container ?