Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bash scripting rsync: rsync: link_stat (blah) failed: No such file or directory (2)

I am trying to write a simple bash script for my local (Mac OS X) machine to move files from a directory on my machine to a remote machine. This line is failing:

rsync --verbose  --progress --stats --compress --rsh=ssh \       --recursive --times --perms --links --delete \       --exclude "*bak" --exclude "*~" \       /repository/* $DEV_SERVER:$REMOTE_DIR 

$DEV_SERVER and $REMOTE_DIR are defined previously, and I echo them to verify they're accurate.

The error I'm getting is:

rsync: link_stat /Users/myusername/mycurrentdirectory failed: No such file or directory (2) 

To note here is that rather than using the defined directory (/repository, which is in the root of the machine), it uses my working directory. What is causing this?

like image 516
Nathaniel Ford Avatar asked May 23 '12 19:05

Nathaniel Ford


2 Answers

Check that your \ characters have no whitespace after them at the end of the line. This will cause BASH to not interpret the line wrap correctly, giving the rsync error above.

like image 95
Martin Smith Avatar answered Sep 28 '22 07:09

Martin Smith


Remove the '*' from the source location, rsync knows to look in the inside of the directory if you specify the '/' in the end

like that:

rsync --verbose  --progress --stats --compress --rsh=ssh --recursive --times --perms --links --delete --exclude "*bak" --exclude "*~" /repository/ $DEV_SERVER:$REMOTE_DIR 
like image 25
Garry Gerber Avatar answered Sep 28 '22 07:09

Garry Gerber