Copying docker image folder between partition with rsync

2.2k views Asked by At

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.

2

There are 2 answers

1
chilladx On BEST ANSWER

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

0
itsafire On

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