On 3/3/06, Raymond Norton <admin at lctn.org> wrote:
> I'm setting up a new mail server and have moved over the necessary user
> files. Is there a way to copy the info from the old
> server  /etc/passwd, /etc/group , and /etc/shadow to the same files on
> the new server, without writing over existing entries or creating
> duplicates?
>

There may be a better way, but I always use Vim. I've thought about
scripting it, but after seeing all the strange UID assignments that
occur, I've decided I would like to see things myself. The whole
process usually only takes 5 - 10 minutes.

In my situation, the new server just has system UIDs and a few newly
created users so it's usually just a cut and paste. You just have to
make sure that their aren't any conflicts.  The home directories also
need to be there.  I handle the /etc/group file in the same way.

I know on Redhat and Debian based distros (so probably others too)
have the pwck and grpck commands that point out any errors or
conflicts which makes the process even easier.

If your new server has a lot of non-system entries already, you may
want to think about writing a script to change the old UIDs by
incrementing with the largest UID on the new system.  That way you
shouldn't have any conflicts.

One thing to look out for is file permissions. If you need to change
the UIDs of your users and they had ownership of files, you may have a
hard time getting the permissions back to working order. It's easy if
they only had files in their home directory and all the files can have
the same perms, but otherwise in can be a major PITA.

Let us know if you find a better solution. I know I would appreciate
it, but don't have any time to look for one.

-Eric