Debian – Preserve ownership with rsync and nonexistent user

debianpermissionsrsyncsynchronizationusers

I have two computers with the same user, me@Home and me@Work. I usually kept their folders synced by bringing Work home (it's a laptop) and rsyncing over LAN. However, now I'm not bringing Work home anymore, so I started using the uni's ssh server to keep my computers synced.

me@Work -> my_name@Uni
me@Home <- my_name@Uni

However, when rsyncing from Work to Uni, using -avuz, which should preserve ownership, file ownership is lost. I made some tests and the issue seems to be the unmatched "me" user at Uni. Not only that, directories owned by www-data also didn't have their ownership preserved (since there isn't such user at Uni either), which, one can imagine, caused me some trouble. I don't have root access at Uni nor can my username be changed. Is there anyway I can make this work without setting up a ssh server myself or start bringing Work home again?

Best Answer

rsync can't preserve ownership if it's being run by a non-root user on the destination system, because only the superuser is allowed to create files that are owned by someone else. Instead of using rsync create a tar file on the intermediate system. Then when you restore it on the ultimate target system, you can do so as root in order to give the original ownership to the files.

Related Question