Skip to content
Backup all volumes belonging to a docker container
Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE
README.md
backup-docker.sh

README.md

Docker volumes backup

This script allows you to backup all volumes from a container in a tar.gz file

Backup a container

$ ./backup-docker.sh [Your container]

Example

$ ./backup-docker.sh mysql
$ Backup docker s volume(s) from : mysql
$ Pause docker container : mysql
$ Backup datas from mysql container
$ Unpause docker container : mysql
$ Output file name : mysql_31-Aug-2015_21-16-35.tar.gz
$ Done.

Restore a container

Run your docker container

$ docker run --volumes-from [Your container] -v $(pwd):/backup ubuntu bash -c "tar xf /backup/[Backup_file].tar.gz"

Example

$ docker run --name mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:tag
$ docker stop mysql
$ docker run --volumes-from mysql -v $(pwd):/backup ubuntu bash -c "tar xf /backup/mysql_31-Aug-2015_21-16-35.tar.gz"
$ docker start mysql

LICENSE

This script is licensed under the MIT Open Source license. For more information, see the LICENSE file in this repository.

You can’t perform that action at this time.