Hi there, I set up my company's back up server using rsync. And I've got a strange problem. I searched in the archives of this list, but none of them seems not giving me an idea to solve the problem. If anyone can help, it would be grateful. I'm using cron by a user (non wheel/admin) to rsync everyday during the night. The cron is set in the server to transfer the backing-up directories to a remote server. My shell script is as follows. I make up the proper command by the script. The user is authenticated by RSA non password. The problem is, I can run successfully with the command, which was produced by the script, from the command line. But if I run this script from cron or run this script on command line, link_stat error occurs. The directory /home/auser/ is the current directory when the command is run. How can I get rid of that? I tried "::" instead of single colon. I don't use rsyncd.conf file, because I think it runs as non daemon process. This is a single command for back-up: rsync -auzv -e ssh --delete --exclude=".*" --exclude="~*" /work/data my.remote.domain:/ftproot/friday >> friday.log Any comment would be appreciated. A. Uchida Error message:> rsync: link_stat "/home/auser/my.remote.domain:/ftproot/friday" > failed: No such file or directory (2) > rsync: link_stat "/home/auser/>>" failed: No such file or directory > (2) > done > ERROR: destination must be a directory when copying more than 1 file > rsync error: errors selecting input/output files, dirs (code 3) at > main.c(412) > rsync: connection unexpectedly closed (8 bytes received so far) > [sender] > rsync error: error in rsync protocol data stream (code 12) at io.c > (434)my script;> #!/bin/sh > > bDir="/work/data" > rSvr="my.remote.domain" > rDir="/ftproot/" > attr="-auzv -e ssh --delete --exclude=\".*\" --exclude=\"~*\"" > > case `date +%a` in > Mon) > tDay="sunday" > yDay="saturday";; > Tue) > tDay="monday" > yDay="friday";; > Wed) > tDay="tuesday" > yDay="monday";; > Thu) > tDay="wednesday" > yDay="tuesday";; > Fri) > tDay="thursday" > yDay="wednesday";; > Sat) > tDay="friday" > yDay="thursday";; > Sun) > tDay="saturday" > yDay="friday";; > esac > > sufx=">> $tDay.log" > #command="rsync $attr $bDir $rSvr:$rDir$tDay $sufx 2>&1" > > echo `date` > $tDay.log > > if test $tDay != "saturday" && test $tDay != "sunday"; then > rsync $attr $bDir $rSvr:$rDir$tDay $sufx > else > echo not on duty in a weekend >> $tDay.log > fi > > echo `date` >> $tDay.log
On Saturday 23 Jul 2005 13:40, livau@gmx.net wrote:> Hi there, > > I set up my company's back up server using rsync. > And I've got a strange problem. I searched in the archives of this > list, but > none of them seems not giving me an idea to solve the problem. > If anyone can help, it would be grateful. > > I'm using cron by a user (non wheel/admin) to rsync everyday during > the night. > The cron is set in the server to transfer the backing-up directories > to a remote server. > > My shell script is as follows. > > I make up the proper command by the script. The user is authenticated > by RSA non password. > The problem is, > I can run successfully with the command, which was produced by the > script, from the command line. > But if I run this script from cron or run this script on command > line, link_stat error occurs. > The directory /home/auser/ is the current directory when the command > is run. > How can I get rid of that? > I tried "::" instead of single colon. > I don't use rsyncd.conf file, because I think it runs as non daemon > process. > > This is a single command for back-up: > rsync -auzv -e ssh --delete --exclude=".*" --exclude="~*" > /work/data my.remote.domain:/ftproot/friday >> friday.logtry user@my.remote.domain and cd /home/auser or put the full path in, if it isn't already> > Any comment would be appreciated. > A. Uchida > > Error message: > > rsync: link_stat "/home/auser/my.remote.domain:/ftproot/friday" > > failed: No such file or directory (2) > > rsync: link_stat "/home/auser/>>" failed: No such file or directory > > (2) > > done > > ERROR: destination must be a directory when copying more than 1 file > > rsync error: errors selecting input/output files, dirs (code 3) at > > main.c(412) > > rsync: connection unexpectedly closed (8 bytes received so far) > > [sender] > > rsync error: error in rsync protocol data stream (code 12) at io.c > > (434) > > my script; > > > #!/bin/sh > > > > bDir="/work/data" > > rSvr="my.remote.domain" > > rDir="/ftproot/" > > attr="-auzv -e ssh --delete --exclude=\".*\" --exclude=\"~*\"" > > > > case `date +%a` in > > Mon) > > tDay="sunday" > > yDay="saturday";; > > Tue) > > tDay="monday" > > yDay="friday";; > > Wed) > > tDay="tuesday" > > yDay="monday";; > > Thu) > > tDay="wednesday" > > yDay="tuesday";; > > Fri) > > tDay="thursday" > > yDay="wednesday";; > > Sat) > > tDay="friday" > > yDay="thursday";; > > Sun) > > tDay="saturday" > > yDay="friday";; > > esac > > > > sufx=">> $tDay.log" > > #command="rsync $attr $bDir $rSvr:$rDir$tDay $sufx 2>&1" > > > > echo `date` > $tDay.log > > > > if test $tDay != "saturday" && test $tDay != "sunday"; then > > rsync $attr $bDir $rSvr:$rDir$tDay $sufx > > else > > echo not on duty in a weekend >> $tDay.log > > fi > > > > echo `date` >> $tDay.log-- ----------------- Bob Hutchinson Midwales dot com -----------------
On Sat, Jul 23, 2005 at 01:40:08PM +0100, livau@gmx.net wrote:> rsync $attr $bDir $rSvr:$rDir$tDay $sufxThis is a shell-programming error -- this tells rsync to copy 3 local files to a dir name that is the last word in $sufx, which happens to be a file named friday.log. Thus, rsync complains that two local files in the current directory don't exist, one with a weird name (based on your $rSvr:$rDir$tDay expansion) and one with the name ">>" (which was word-split out of $sufx). You need to remove all shell-special characters from inside variables because the shell does not evaluate them inside a variable expansion (not without using "eval" to tell the shell to re-parse the resulting string). Explicitly, you'd need to dump the ">>" from $sufx and remove the double-quotes from inside $attr. Then, change your rsync-executing line to this: rsync $attr $bDir $rSvr:$rDir$tDay >> $sufx ..wayne..