container to backup and restore your mysql database's to using awscli.
-
This container user cron to make backups
-
Mysql will dump the database to this container and compress it using gzip
-
Using s3cli the file will be uploaded to S3 Storage
-
To restore a db just enter the container and run the 'restore' script with the file name to restore:
./restore example.sql.gz
-
To run a manual backup just enter the container and run:
./backup
-
$MYSQL_PASSWORD
- The password to connect with Mysql. -
$MYSQL_USER
- The username to connect with Mysql. -
$DB_NAME
- Database name. -
$AWS_ACCESS_KEY_ID
- Aws acess key. -
$AWS_SECRET_ACCESS_KEY
-Aws secret key. -
$BUCKET
- Aws bucket name . -
$REGION
- Aws region where your bucket is. -
$MYSQL_PORT
- Port to connect with Mysql. default 3306. -
$MYSQL_HOST
- Host where mysql is running. -
$FILENAME
- Name to file in Azure Storage. Default namedefault-date +"%Y-%m-%d_%H-%M"
output exampledefault-2015-08-03_17-58
-
$BACKUP_WINDOW
- What time should backup run. you should use crontab format, so see [documentation](http://www.freebsd.org/cgi/man.cgi?crontab(5). default value every day at 6 am. -
$SLACK_WEBHOOK
- Put the Webhook URL here -
_ NOT WORKING!
$SLACK_TOKEN
_ - Your slack token. NOT WORKING! -
_ NOT WORKING!
$SLACK_CHANNEL
_ - Slack channel to send message. NOT WORKING!
docker run --rm --name mysql-backup \
--env AWS_ACCESS_KEY_ID=AKIAIDHJDJCCC2KM4SSA \
--env AWS_SECRET_ACCESS_KEY=HT1PWzBN5sjVPFHCuTX+VQs+8nQ00KteoI44iBfz \
--env BUCKET=backups.example.com \
--env REGION=eu-west-1 \
--env FILENAME=backup \
--env MYSQL_HOST=test.mysql.net \
--env MYSQL_USER=root \
--env MYSQL_PASSWORD=password \
--env DB_NAME=mysql-db \
--env BACKUP_WINDOW='0 6 * * *' \
--env SLACK_WEBHOOK=https://hooks.slack.com/services/XXXXXXXXXXX \
bsdigital/docker-mysql-backup-s3
This will upload to Aws S3 a file named backup-2015-08-04_09-47.sql.gz
.
docker build -t bsdigital/docker-mysql-backup-s3 .