Backing up and restoring a system user account

backuppamusers

How would I go about completely backing up a user account and restoring it on a new system? The Home directory is just 'copy-and-paste'. But then what about things like the account password; and its UID and GID?

The accounts are being used by Dovecot SASL to provide authentication for Postfix, services, and other applications. So I'm worried that I won't get everything in the backup; or risk not being able to fully recover the valuable user data.

The system is Ubuntu 11.04.

Best Answer

If you are doing backup and restore by hand, then things are relatively easy, especially if the new system is (nearly) completely new.

I doubt if you really need to backup and restore password, UID and GID. However, if you know the user password (which you should anyway), then you can change the password of the user on the new system accordingly. UID and GID can be assigned on user creation (look at -u and -g from useradd), or modified with usermod. The only problem is if you have created accounts on the new system, which may have taken the UID and GID, in which case you need to change that account first.

UID and GID only make sense if you have preserved permissions when copying files (see --preserve=mode from cp). All applications that I have used (not that I have used all application) use username and not UID or GID for configuration, so I don't think that will be a problem.

If you want a program where you can say "Backup this user!" on a machine and then "Restore that user!" on another machine then I don't know how a program could possibly do it ;) Breakage may occur, but if you have the config files under control you should not be afraid. If you have all the files, you can fix it!

Related Question