[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

old vs new system uid/gid



It would be very handy if, while creating a new system, I could replicate the 
uid and gid's of an old one--by which I mean replicate the mapping of numbers 
to names.  I want to restore the old system, and my backup system (bacula) 
uses numeric uid/gid only.  My backups have all the customized files, including 
/etc, but don't have standard ones, in particular /usr.

Any suggestions how to go about this?  I can think of 3 general strategies, 
none without problems.

1. Copy passwd and related files.
Debootstrap the new system and then copy the old passwd, group and shadow files 
over the exiisting ones.  I suppose it would be safer to have a script read 
the old files and do adduser/addgroup as appropriate, since that would assure 
the home directories existed (and maybe do other stuff I'm not aware of).

I'm not sure if creating accounts before installation of the packages that 
usually create the accounts will screw up the proper setup of the packages and 
accounts.

A problem with this strategy is that the installation procedure creates some 
accounts early on, and I'm not sure I can intervene before that point.  The 
new system* has libuuid with uid 100; ssh is 101; the old system had ssh at 
100 and no libuuid at all.

2. Restore old system and upgrade it.
Restorethe old system into a VM and then upgrade.  It would be a big upgrade, 
Lenny->wheezy (needs to be lenny->squeeze->wheezy to be supported) and 32 to 
64 bit (which is not officially supported at all, though there's stuff around the 
net).  

I think this needs to be done in a VM not a chroot, since the latter will get 
its uid/gid info from the host system.

This also has some uid syncronization issues since I must recreate the system 
before putting the files onto it; these should be less acute since a variant of 
1 should work more cleanly.

3. Clean up afterwards.

Restore the old files with the old ids, install the necessary packages to 
create all relevant accounts, and then make a script to swizzle the old ids to 
new ones.

Since I use VMs I should probably be using LDAP, but I think that's best left 
for later.

(*) I expect I will need to recreate this new system; it is temporary but has 
the 64 bit wheezy environment I'm targetting.  The ids on the temporary system 
are already significantly different from those of the old one.  The old system 
and disk died (32 bit lenny).  I have backups but not complete  disk images; 
e.g., I didn't back up /usr. 


Reply to: