Sign inSign up

gleez/xtrabackup

By gleez

•Updated over 9 years ago

Percona Xtrabackup installed and a simple bash script to run the backup command

Image
1

1.9K

gleez/xtrabackup repository overview

⁠Percona Xtrabackup

Derived from the official Docker Debian Jessie image. The image contains Percona Xtrabackup installed and a simple bash script to run the backup command.

⁠How to use this image?

To run the backup, link it to the running MySQL container and ensure to map the following volumes correctly:

  • MySQL datadir of the running MySQL container: /var/lib/mysql
  • Backup destination: /backups

⁠Example

Suppose you have a MySQL container running named "mysql-server", started with this command:

$ docker run -d \
--name=mysql-server \
-v /storage/mysql-server/datadir:/var/lib/mysql \
-e MySQL_ROOT_PASSWORD=mypassword \
mysql

Then, to perform backup against the above container, the command would be:

$ docker run -it \
-v /storage/mysql-server/datadir:/var/lib/mysql \
-v /storage/backups:/backups \
--rm=true \
gleez/xtrabackup \
sh -c 'exec /xtrabackup.sh'

You should see Xtrabackup output on the screen. Ensure you get the “completed OK” line indicating the backup is successful:

...
innobackupex: Backup created in directory '/backups/2017-01-17_17-07-54'
160617 17:07:57  innobackupex: Connection to database server closed
160617 17:07:57  innobackupex: completed OK!

The container will then exit (the "run" is executed interactively) and automatically removed by Docker since we specified “--rm=true” in the command line. On the machine host, we can see the backups are there:

$ ls -1 /storage/backups/
2017-01-17_13-01-58
2017-01-17_13-07-28
2017-01-17_14-02-50
⁠Cron Example
# Run the daily and weekly jobs
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root

30 01 * * *	root	docker run -i --rm=true -v /volumes/mysql:/var/lib/mysql -v /home/backup:/backups --link mysql-server:mysql gleez/xtrabackup bash -c 'exec /xtrabackup.sh incr' >> /var/logs/backup-daily.log
30 00 * * 0	root	docker run -i --rm=true -v /volumes/mysql:/var/lib/mysql -v /home/backup:/backups --link mysql-server:mysql gleez/xtrabackup bash -c 'exec /xtrabackup.sh full' >> /var/logs/backup-weekly.log

Tag summary

Content type

Image

Digest

Size

82.4 MB

Last updated

over 9 years ago

docker pull gleez/xtrabackup