Docker mysql backup image that periodically backs up a mysql database, compresses it, and uploads it using scp.
| Name | Description |
|---|---|
| CRON_SCHEDULE | Cron schedule in crontab format |
| MYSQL_HOST | Host where mysql is running |
| MYSQL_PORT | Port to connect (3306 default) |
| MYSQL_USER | Username to connect with |
| MYSQL_PASSWORD | Password to connect with |
| MYSQL_DATABASE | Name of mysql database to backup (optional) |
| UPLOAD_HOST | Server to SCP the file to |
| UPLOAD_USER | SSH Username |
| UPLOAD_TARGET | Path to upload the backup to |
| UPLOAD_SSHKEY | Private key to use when connecting to ssh |
There is an included docker-compose file for testing.
It mounts the public key in test/ssh/id_rsa.pub to an
imaginary backup server, and then attempts to backup the database
every minute.
When the backup server runs, it will change the permission of
id_rsa.pub. You must chown it back to your current user
and group prior to calling docker-compose again.
Because of this, I recommend using the following command to run the docker-compose file
sudo chown <user>:<group> test/ssh/id_rsa.pub && docker-compose up --build
Replacing user and group with your username and linux group, respectively.