Advertisement
Guest User

migrate.sh

a guest
Feb 1st, 2015
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #!/bin/bash
  2. echo "This will migrate all the user account from this server to a new one"
  3. mkdir /root/move/
  4. export UGIDLIMIT=500
  5. awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/passwd > /root/move/passwd.mig
  6. awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/group > /root/move/group.mig
  7. awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534) {print $1}' /etc/passwd | tee - |egrep -f - /etc/shadow > /root/move/shadow.mig
  8. cp /etc/gshadow /root/move/gshadow.mig
  9. tar -zcvpf /root/move/home.tar.gz /home
  10. tar -zcvpf /root/move/mail.tar.gz /var/spool/mail
  11. echo "Please enter the IP to migrate to: "
  12. read input_variable
  13. echo "Please enter the SSH port: "
  14. read input_variable2
  15. scp -P $input_variable2 -r /root/move/* root@$input_variable:/root/
  16. scp -P $input_variable2 -r /root/import.sh root@$input_variable:/root/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement