A cron job backs up the named volumes of all running containers to S3.
It loops through all the running containers and does the following.
- Stops the container
- Loops over all the containers named volumes
- Backs up each volume to S3
- Starts the container
If you are running dockers on servers you control (as opposed to something like Amazon container manager or Google container engine) this strategy may make sense.
If we were running in a managed environment, we would need to put all this logic inside a docker. Which we may yet do.
We use an S3 bucket that has versioning turned on, so it keeps every backup for x number of days. You can restore just the latest version or a specified version.
Run the backup every night at 8 AM UTC, and send the output to syslog.