Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copying docker image folder between partition with rsync

I'd like to move my /var/lib/docker data to another place, and to make it safe, i'd like to use rsync.

But the data are stored with sparse files, and rsync does not seem to handle it properly.

What would be the right parameters for rsync?

  • -a preserves properly the uid/gid+rights
  • -S handle sparse files efficiently, but rsync never seems to end

Without -S, rsync tries to copy more data than the original location can contain (100G on a 48G partition). With the -S, I seem to be stuck forever after about 10G.

like image 635
chilladx Avatar asked Sep 11 '25 01:09

chilladx


2 Answers

It seems that rsync -avXS is working like a charm.

like image 125
chilladx Avatar answered Sep 13 '25 14:09

chilladx


Should you rsync a /var/lib/docker to a remote server be sure to tell rsync to do no mapping of the uids and gids between the two systems. Otherwise you could end up with wrong ownerships of files in your containers.

so this would create an exact copy:

rsync -avHXS --numeric-ids /var/lib/docker/. [email protected]:/var/lib/docker
like image 34
itsafire Avatar answered Sep 13 '25 14:09

itsafire