Bash scripting rsync: rsync: link_stat (blah) failed: No such file or directory (2)
Solution 1
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.
Solution 2
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
Solution 3
I was encountering the same error while doing some rsync work. I had the wrong character for specifying options which I must have gotten from copying and pasting the command from elsewhere:
−
rather than the correct character below:
-
Nathaniel Ford
Languages: Python, Rust, Go, Bash, Scala, Java, SQL, Scheme. Background: Web Applications, Mono/Micro/Macroservices, CI/CD Infra, Distributed Infra.
Updated on July 15, 2022Comments
-
Nathaniel Ford almost 2 years
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? -
jordanm almost 12 yearsHow does bash handle it differently in non-interactive sessions?
-
Gilles Quenot almost 12 yearsBetter suited for superuser.com
-
shellter almost 12 yearsThe only problem I've had with using the line-continuation-char (i.e.
`), on cmd-line OR in a script, is when there is any character besides a
\n` character after it. I didn't downvote your answer, but I don't think it's right. Good luck to all. -
holgero over 11 yearsThis is plain wrong. Bash interprets a script exactly the same way as it interprets input from the command prompt.
-
nishantjr over 9 yearsThere's not difference in the syntax for interactive and non-interactive shell.
-
Snidhi Sofpro over 3 yearsIn my case, this error occured when the rsync -e option was supplied with an empty string or a space char AND the target file (to be synced with) did not already exist. (The -e option value was being determined conditionally).
-
timotgl over 2 yearsthanks, that was a subtle one! Ran into exactly this when copy-pasting rsync arguments from various websites.