Copy Docker Volume to other host

Disclamer

Of course there are a milion ways to skin this cat. This is a quick and easy one that i like to use:

How-To

Host 1

On both hosts i am in the directory /backup.

mkdir /backup
cd /backup

Show the docker volumes to find the correct name:

user@host1:/backup# docker volume list
DRIVER    VOLUME NAME
local     wikijs_db-data

Create a temporary docker container that puts the data into an archive:

docker run --rm -v wikijs_db-data:/volume -v $(pwd):/backup busybox tar cvf /backup/volume_backup.tar /volume

Copy the archive to the other host:

user@host1:/backup$ scp volume_backup.tar host2:/backup
volume_backup.tar                                                    100%  143MB   5.4MB/s   00:26

Host 2

Go into the /backup directory:

cd /backup

Create the volume if it does not exist:

docker volume create wikijs_db-data

Again, create a temporary docker container that puths the data into the volume:

docker run --rm -v wikijs_db-data:/volume -v $(pwd):/backup busybox tar xvf /backup/volume_backup.tar -C /
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
Scroll to Top