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

52,189

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:

-
Share:
52,189
Nathaniel Ford
Author by

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, 2022

Comments

  • Nathaniel Ford
    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
    jordanm almost 12 years
    How does bash handle it differently in non-interactive sessions?
  • Gilles Quenot
    Gilles Quenot almost 12 years
    Better suited for superuser.com
  • shellter
    shellter almost 12 years
    The 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
    holgero over 11 years
    This is plain wrong. Bash interprets a script exactly the same way as it interprets input from the command prompt.
  • nishantjr
    nishantjr over 9 years
    There's not difference in the syntax for interactive and non-interactive shell.
  • Snidhi Sofpro
    Snidhi Sofpro over 3 years
    In 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
    timotgl over 2 years
    thanks, that was a subtle one! Ran into exactly this when copy-pasting rsync arguments from various websites.