/ docker

Docker + Backup = Dockup

Yesterday, I was called out by a colleague after he discovered I was backing up my Docker environments to Amazon S3 with some bash scripts and a crontab entry. This is a working solution but he asked ever so politely why I was not running this in a Docker container? As I buried my head in shame I decided to get cracking and move my backups into a container.

He informed me that he started his Docker project recently and was using
Tutum's Dockup Docker + Backup = Dockup to perform Docker volume backups. I researched Dockup and dug through the code and decided it was a good match for my projects.

Dockup backups up your Docker Container volumes and is really easy to configure and get running. Configuring Dockup is straightforward and all the settings are stored in a configuration file env.txt. Here we define what volumes from what containers to backup and to which Amazon S3 bucket to store the backup.


PATHS_TO_BACKUP=/etc/mysql /var/lib/mysql

I initially ran Dockup on this blog and it created a Tar file in my Amazon S3 bucket and exited as the docker run command is setup to cleanup. After some investigating it turns out that Dockup already supports Cron jobs but was not documented so as in true Open Source spirit I created a Pull Request on the Dockerup project and added instructions on how to run and use the CRON_TIME variable.

S3 Backup Retention Time

If you are running this as a cron job then Dockup will backup your data into S3 until the cows come home or your credit card refuse, whichever comes first. To prevent this I setup a retention time inside of S3 to ensure backups older than N days old will be automatically purged by S3. Inside your S3 bucket properties navigate to Lifecycle and create a rule to remove objects after a certain amount of time. I've selected 120 days in my example.

S3 Backup Retention

Next Steps

I haven't decided if I will keep the cron job running in the container or remove the container and create a cronjob on my Docker Host which launches the container at backup time. Either way it is only a small detail. Next, I will try to incorporate all my docker-compose files also in the backup strategy to ensure all my configurations are backed up as well.

Brian Christner

Brian Christner

Brian's spent a large portion of his career in the casino industry where he made sure the house always won. Brian is a nominated member of the Docker Captain’s program and a seasoned cloud architect.

Read More