Sunday, February 15, 2015

rsync files from one system to another

#!/bin/ksh
#************************************************************************
# This script will rsync filesystems under /sasdata & /appdata            *
# from my_S_host over to my_target_host                                *
#************************************************************************
SOURCE_HOST=my_S_host
TARGET_HOST=mytarget_host
SOURCE_FS=/var/tmp/fs_my_S_host.tmp
MAXTHREADS=5
SLEEPTIME=5
grep -v "^#" ${SOURCE_FS}|while read FileSystem
do
        while [ `ps -ef | grep -c [r]sync` -gt ${MAXTHREADS} ]
        do
                echo "Sleeping ${SLEEPTIME} seconds"
                sleep ${SLEEPTIME}
        done
        echo "\nRunning rsync in background to copy ${FileSystem} over to ${TARGET_HOST}:${FileSystem} ...."
        nohup rsync -aAHx ${FileSystem}/ ${TARGET_HOST}:${FileSystem}/ </dev/null >/dev/null 2>&1 &
done
bash-3.2#

-------------------------------------------------------------------------
#!/bin/sh
D_HOST=mytarget_host
C_FILE=/var/tmp/myFS.txt
for i in `cat ${C_FILE}`
do
 echo "Syncing $i to ${D_HOST} . Please wait ...."
 /usr/bin/rsync -logtprz --exclude-from=/var/tmp/my.opt.exclude --progress --rsh='ssh -l root' $i root@${D_HOST}:$i
done

No comments:

Post a Comment