mkdir /root/migracion
export UGIDLIMIT=500
##migrar /etc/passwd
awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/passwd > /root/migracion/passwd.mig
##migrar /etc/group
awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/group > /root/migracion/group.mig
##migrar /etc/shadow
awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534) {print $1}' /etc/passwd | tee - |egrep -f - /etc/shadow > /root/migracion/shadow.mig
##migrar /etc/gshadow
cp /etc/gshadow /root/migracion/gshadow.mig
##backup home
tar -zcvpf /root/migracion/home.tar.gz /home
##Pasar
scp -r /root/migracion root@192.168.131.198:/root/
##IMPORTANDO
Bacapear usuario del sistema
mkdir /root/users.bk
cp /etc/passwd /etc/shadow /etc/group /etc/gshadow /root/users.bk
##Restaurar
cd /root/migracion
cat passwd.mig >> /etc/passwd
cat group.mig >> /etc/group
cat shadow.mig >> /etc/shadow
/bin/cp gshadow.mig /etc/gshadow
## Parado en el /
tar -zxvf /root/migracion/home.tar.gz
reboot
export UGIDLIMIT=500
##migrar /etc/passwd
awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/passwd > /root/migracion/passwd.mig
##migrar /etc/group
awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/group > /root/migracion/group.mig
##migrar /etc/shadow
awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534) {print $1}' /etc/passwd | tee - |egrep -f - /etc/shadow > /root/migracion/shadow.mig
##migrar /etc/gshadow
cp /etc/gshadow /root/migracion/gshadow.mig
##backup home
tar -zcvpf /root/migracion/home.tar.gz /home
##Pasar
scp -r /root/migracion root@192.168.131.198:/root/
##IMPORTANDO
Bacapear usuario del sistema
mkdir /root/users.bk
cp /etc/passwd /etc/shadow /etc/group /etc/gshadow /root/users.bk
##Restaurar
cd /root/migracion
cat passwd.mig >> /etc/passwd
cat group.mig >> /etc/group
cat shadow.mig >> /etc/shadow
/bin/cp gshadow.mig /etc/gshadow
## Parado en el /
tar -zxvf /root/migracion/home.tar.gz
reboot
Comentarios