i want to back up server which is the easy way to backup or sync it ??
May I suggest to be more specific about what exactl you want to backup or sync?
i want to backup whole docker or docker compose file
like what if i want keep container that i install
then i want to install new os & i restore it.
or automatic sync docker to cloud.
âWhole dockerâ == the whole docker engine installation from /var/lib/docker?
âWhole dockerâ == the whole conantainer including the image and all volumes?
I doubt that backing up /var/lib/docker and restoring it will succeed as overlay2 will present a virtual filesystem for each image/container, which might be interpreted as physical files. Never tried it though, as I donât trust this approach. If you compare sudo du --human-readable --max-depth=1 --one-file-system /var/lib/docker
and sudo docker system df
, both should show the same size. But if you ue the command sudo du --human-readable --max-depth=1 /var/lib/docker
will show a different result, as files are counted multiple times - I would expect a backup to backup files multiple times and âbreakâ the overlay2 âmagicâ when it restores the files.
Personaly, I would solve it in a different way:
- instead of backing up images:
- run a private container registry
- use the registry to pull through the images
- instead of backing up docker-compose file:
- keep the docker-compose.yml and all files required by it in git
- instead of backing up a while container
- backup all volumes of containers (for the sake of consistency with stopped container)
- you can use muesli . for it
- sync the backups to a target environment
- backup all volumes of containers (for the sake of consistency with stopped container)
Update: I realized I missed the most imortant part âwhat is the easiest wayâ. I hav no idea what the easiest way is. I just know how to backup the relevant parts in a consistent way - but I am afraid it fails on the requirement of beeing easy.
please advice the image and all volume method.
@meyay just did that. Read his list of recommendations again. Do you have a more specific question?
do i need to git clone before use git add .