Hi,
I wanted to write a shell script wrapper for automatically syncing some folders across machines. The machines are spread over two sub-domains in the parent domain (
grp.vpncc.org and
hpc.vpncc.org). I have set up public and private keys over the machines so that I can rsync without password. I have three machines
archean, jurassic and silurian under
grp.vpncc.org which uses a central nfs mounted home directory (
/nfs/cretaceous/home/). From these three machines I usually would like to run this syncing. The fourth machine of my interest is
cluster.hpc.vpncc.org, but this is I have checked individual rsync commands and that works fine. But when I try to use rsync via the script (autosync.sh):
Code:
#!/bin/bash
arg=$1
usr="somesh@$2"
src=$3
dest=$4
host=`hostname`
case $host in
archean.grp.vpncc.org)
key="\"ssh -i /home/somesh/.keys/archean_rsa\""
;;
silurian.grp.vpncc.org)
key="\"ssh -i /home/somesh/.keys/silurian_rsa\""
;;
jurassic.grp.vpncc.org)
key="\"ssh -i /home/somesh/.keys/jurassic_rsa\""
;;
*)
echo "Non Destination:" $host
;;
esac
echo $arg
echo $key
echo $usr
echo $src
echo $dest
f="rsync $arg -e $key $usr:$src $dest"
echo $f
rsync $arg -e $key $usr:$src $dest
I get this error:
Code:
somesh@archean temporst$ ./autosync.sh -avz cluster.hpc.vpncc.org /gpfs/home/somesh/myScripts/ .
-avz
"ssh -i /home/somesh/.keys/archean_rsa"
somesh@cluster.hpc.vpncc.org
/gpfs/home/somesh/myScripts/
.
rsync -avz -e "ssh -i /home/somesh/.keys/archean_rsa" somesh@cluster.hpc.vpncc.org:/gpfs/home/somesh/myScripts/ .
building file list ... rsync: link_stat "/home/somesh/.keys/archean_rsa"" failed: No such file or directory (2)
rsync: link_stat "/nfs/cretaceous/home/somesh/myScripts/temporst/somesh@cluster.hpc.vpncc.org:/gpfs/home/somesh/myScripts/." failed: No such file or directory (2)
done
sent 29 bytes received 20 bytes 98.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files could not be transferred (code 23) at main.c(892) [sender=2.6.8]
But when I use the command
Code:
rsync -avz -e "ssh -i /home/somesh/.keys/archean_rsa" somesh@cluster.hpc.vpncc.org:/gpfs/home/somesh/myScripts/ .
it works fine.
What am I doing wrong?
All the systems run RHEL 5 or CentOS 5.
TIA,