[Discuss] rsync v. cp in data migration

Greg Rundlett (freephile) greg at freephile.com
Sat May 25 09:32:02 EDT 2013


This is the script I ended up using: (in color: http://pastebin.com/une2RYq2
)

Because the SOURCE wasn't NFS mounting, I ended up adding back in the -z to
rsync and the network portion is over SSH rather than NFS.

642GB have been copied so far.  18 of 149 users are complete and everything
looks good.

cat /root/bin/copy.home.dirs.sh
#!/bin/bash -e
# run bash with -e to exit on errors

# create a function that we can attach a signal to
# in case we want to stop this script
# otherwise if we press Ctrl-C, it will just continue
# with the next iteration in the loop
cleanup ()
{
kill -s SIGTERM $!
exit 0
}
# now set the trap
trap cleanup SIGINT SIGTERM
SOURCE=a.example.com
LOGFILE=home.copy.log

# we will use a prepared file 'users' whose contents are a list of users,
one user per line
while read USER
do echo "Working on $USER" | tee -a $LOGFILE
TIMING="$(time ( rsync -avSHPz root@$SOURCE:/home/$USER/ /nas_home/$USER/ )
2>&1 1>/dev/null )"
echo $TIMING | tee -a $LOGFILE
echo "/home/$USER copied to new NAS" | tee -a $LOGFILE
echo "" | tee -a $LOGFILE
done < "users"

Greg Rundlett



More information about the Discuss mailing list