Rsync many solaris server’s non-OS filesystems in parallel

This one will run rsyncs in the background for each host it finds in hosts.txt, and save each host’s progress in a log.

#!/bin/ksh
for h in `cat hosts.txt`;do
 echo "----------------------- $h"
 (
 ssh $h df -k | egrep -v 'cdrom|^Filesystem|/$|/devices$|/system/contract$|/proc$|/etc/mnttab$|/etc/svc/volatile$|/system/object$|/etc/dfs/sharetab$|/dev/fd$|/tmp$|/var$|/var/run$|/dev/vx/dmp$|/dev/vx/rdmp$|/cores$|/var/crash$' | awk '{ print $NF }' | while read l;do
 mkdir -p /space/$h$l
 echo "rsync --progress -zrtva $h:$l/ /space/$h$l/"
 rsync --progress -zrtva $h:$l/ /space/$h$l/
 done
 ) 2>&1 > ${h}.log &
 done

Leave a Reply

Your email address will not be published. Required fields are marked *