Backing up Docker named volumes
Stopping the Docker Service/Containers
To stop the Docker service on Ubuntu 22.04:
systemctl stop docker
To stop containers:
docker stop <container name>
To stop all containers:
docker stop $(docker ps -a -q)
Source Machine
sudo suto gain root access.cd /var/lib/dockerrsync -av --rsync-path="sudo rsync" volumes/ chunaki@192.168.0.22:/home/chunaki/volumes/
Before you can use
--rsync-path="sudo rsync", you need to set the permissions on the destination machine. 1
- Find out the path to
rsync:which rsync- Edit the
/etc/sudoersfile:sudo visudo- Add the line
<username> ALL=NOPASSWD:<path to rsync>, where username is the login name of the user that rsync will use to log on. That user must be able to usesudo
Target Machine
sudo sucd /var/lib/dockercp -r /home/chunaki7/volumes/* volumes/
References
This post is licensed under CC BY 4.0 by the author.