Restoring from backup, preserving uids
neil at nilspace.com
Sat Aug 2 14:41:53 GMT 2008
Matt McCutchen wrote:
> On Sat, 2008-08-02 at 08:26 -0500, Neil Gunton wrote:
>> 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.
> That's the right idea, but rsync relies on the getpw* functions of the C
> library rather than reading /etc/passwd directly, so the fix wouldn't be
> as simple as adding an option to use a different path to /etc/passwd.
> What you can do that works right now is pull from an rsync daemon
> configured to chroot into the backup so that the daemon's calls to
> getpw* access the /etc/passwd file inside the chroot.
Thanks for the tip. I just took at look at the man page for rsyncd.conf
and it seems to warn you away from combining chroot:
"... disadvantages of ... complicating the preservation of users and
groups by name (see below)."
I can see in principle how to use this, but my first reaction is that it
seems like an overly complex solution to a very common problem. Surely a
tool should aim to make the most commonly used tasks the simplest to
accomplish? I would posit that most people use rsync for system backups,
I have for years, it's only now that I have bothered to talk about the
I'm suggesting that it might be a nice addition to rsync if we could add
an option to use a passwd file for the mapping of the src uids to the
current (dest) uid/username system. This would then mean you don't have
to set up a special chrooted rsync daemon simply in order to do restore
from your local backup drive. Instead you could just do something like:
rsync -av --src-passwd-file=/backup/etc/passwd /backup/etc /
... or some other option name that makes sense, that's just off the top
of my head. This would make restores much simpler. I accept that there's
a workaround via the chroot daemon, and that this would likely require
some refactoring of the rsync code. I'm just making an appeal to
simplicity for something that's done quite commonly. Of course someone
else will have to do the work, so it's just a humble suggestion.
More information about the rsync