Sign inSign up

eidansoft/backup_volumes

By eidansoft

•Updated over 6 years ago

Image
0

1.0K

eidansoft/backup_volumes repository overview

⁠Backup my volumes

The idea is to have a simple (but powerful) command that allow me to easy and quick create a backup for all volumes I have.

The idea cames to my mind due to the need of backup the data saved into the volumes in use by my containers. As I usually manage all my docker instantiations through a docker-compose file, the volumes in use by my containers all have a prefix. So I can get very quickly all volume names in use for any docker-compose:

$ sudo docker volume list | grep local | tr -s ' ' | cut -d ' ' -f 2 | grep "$VOLUME_NAME_PREFIX"

I have used that list and created a couple of scripts that generate a *.tar.gz file for each volume found.

⁠Usage

It's very easy to use, because the docker image contains all needed. Just need to provide the folder where the new *.tar.gz files will be created (BACKUP_FOLDER) and the prefix to identify the volumes you want to backup (VOLUME_NAME_PREFIX). The command to run is:

$ sudo docker run -t --rm -v /var/run/docker.sock:/var/run/docker.sock -e BACKUP_FOLDER=/tmp/my_backups -e VOLUME_NAME_PREFIX=myprefix_ eidansoft/backup_volumes

Note: In order to create a fully self-contained code, the docker container makes use docker it self, for that reason you need to provide at the call a volume with the socket to your docker daemon.

Tag summary

Content type

Image

Digest

Size

21 MB

Last updated

over 6 years ago

docker pull eidansoft/backup_volumes