Migrating Users and Groups from 1 Linux to another:

On source server:

export UGIDLIMIT=500

mkdir /root/move

awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/passwd > /root/move/passwd.mig

cat /root/move/passwd.mig

awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/group > /root/move/group.mig

cat /root/move/group.mig

awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534) {print $1}' /etc/passwd tee - egrep -f - /etc/shadow > /root/move/shadow.mig

cat /root/move/shadow.mig

use scp or sftp to move backup *.mig and *.gz files over to the new server /tmp directory then delete the *.gz files from the source server to free up space

On the target server:

cd /tmp cat passwd.mig >> /etc/passwd

vi /etc/passwd # to verify things look correct vi passwd.img

cat group.mig >> /etc/group

vi /etc/group

cat shadow.mig >> /etc/shadow vi /etc/shadow

cd / tar -zxvf /tmp/home.tar.gz rm -rf /tmp/home.tar.gz

cd / tar -zxvf /tmp/mail.tar.gz rm -rf /tmp/mail.tar.gz

reboot the server once all files have been verified and are correctly formatt

No comments: