Restoring from backup, preserving uids

Neil Gunton neil at
Sat Aug 2 13:26:47 GMT 2008

Hi, I use rsync to back up my Linux system to hard drive. I use the -av 
option, and it preserves uids. However if I reinstall Linux, and try to 
restore from the backup hard drive, the owner permissions get all mixed 
up, I assume since the numeric uids don't match up with the equivalent 
usernames any more. For example, user nobody might have had uid 123 in 
my old system, but now in the new one it gets 456. So when I restore, 
for example, /etc/mail for my sendmail setup, which has very specific 
ownerships on all the files, they all get owned by whatever users happen 
to have those uids. It's a bit of a mess, and makes restoring from a 
hard drive backup much more tricky.

So, first question: Am I missing something here? Am I backing up or 
restoring in the wrong way?

Second question: If I am doing it "right" (using -av) then may I suggest 
a possible solution? I think rsync could match up the "old" uids from 
the backup with the "current" uids in the system if it had access to the 
old /etc/passwd file, which maps the uids to usernames. So would it be a 
good option to add to rsync to give it a path to the "old" passwd file, 
in order to match up the uids in the source dir to the ones in the 
destination? Destination would be assumed to use the current passwd, of 
course. This would help map the old uids to the new ones.

Does that make any sense?



More information about the rsync mailing list