blog-image

Nov 08, 2018

7 min read

Docker Backup: Saving and Restoring Your Volumes

Written by

Vippy The VPS
You don’t have a backup unless you’ve restored your data from it.
The above quote is accurate even in the age of Docker. You need to have a backup of your applications, and, more importantly, your Docker volumes. Volumes are the persistent storage provider for Docker containers, and you can learn more about them here. We’ll pick up where that piece left off and work with the volume we created for our blog based on the Ghost CMS. Docker volumes are supposed to be managed by the Docker daemon, and we don’t want to fiddle with that. The strategy here is to get a copy of a volume as a compressed file in one of our regular directories, like /home/$USER/backups. This compressed copy of the volume then acts as our backup. [cta_inline]

Running a Docker volume backup

First, we spin up a temporary container, and we mount the backup folder and the target Docker volume to this container. When an ordinary directory like ~/backups is mounted inside a Docker container we call it a bind mount. Bind mounts, unlike Docker volumes, are not exclusively managed by Docker daemons, and hence we can use them as our backup folder. The official Docker documentation recommends this behavior, so you know it’s safe to try on your containers and volumes. But before you do take a backup, ask yourself this question: Is the data in this volume changing
Continue reading this article
by subscribing to our newsletter.
Subscribe now

Leave a Reply