Rsync copy fails ("no such file or directory")

34,618

Solution 1

You need to add the connection details, eg. for SSH use --rsh=ssh.

Try:

rsync -avzP --rsh=ssh [email protected]:/public_html/abc/ /www/abc

And make sure the paths are correct. Are these paths absolute or relative: /public_html/abc/, /www/abc?

Solution 2

The error comes from the fact that there is no /public_html/abc directory on the remote system.

According to comments, the source directory is actually located in the user's home directory, not at the path /public_html.

Therefore:

rsync -avzP [email protected]:public_html/abc/ /www/abc

Here, we access public_html/abc in the user's home directory rather than in the root of the filesystem.


The warning stdin: is not a tty comes from the fact that your shell's startup file for interactive shells is being called on the remote host (your ~/.bashrc file, if you are using bash), and you are doing something in it that requires a terminal.

You may edit the shell startup file on the remote machine and insert the following close to the top:

[ ! -t 0 ] && return

This would stop the execution of e.g. ~/.bashrc at that point for all shell sessions whose standard input streams are not attached to a terminal.

Share:
34,618

Related videos on Youtube

killer_rabbit
Author by

killer_rabbit

Updated on September 18, 2022

Comments

  • killer_rabbit
    killer_rabbit over 1 year

    I am just starting to learn how to use rsync, as I am trying to copy files from one server to another. I am using the following command:

    rsync -avzP [email protected]:/public_html/abc/ /www/abc
    

    After entering the other server's password, I then get the following message:

    stdin: is not a tty 
    receiving incremental file list 
    rsync: change_dir "/public_html/abc" failed: No such file or directory (2) 
    sent 8 bytes 
    received 101 bytes  8.72 bytes/sec total size is 0  speedup is 0.00
    rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1655) [Receiver=3.1.1]
    

    However, directory abc does exist, I can browse it etc. There are no spaces in the name.

    Any ideas what this may be caused by?

    • kemotep
      kemotep almost 6 years
      Is /public_html located off of the user /home or / or whatever default directory your ssh session will load you into? When you mean by browse to it do you mean via a web page or via command line once remote?
    • Jeff Schaller
      Jeff Schaller almost 6 years
      Is /abc a web server alias?
    • BowlOfRed
      BowlOfRed almost 6 years
      Looks like your shell might be spitting some odd output. Can you show the output of ssh [email protected] ls -d /public_html/abc? Especially if there is anything besides just the directory shown.
    • killer_rabbit
      killer_rabbit almost 6 years
      Thanks for your comments, guys. @kemotep: yes, the folder is located off the user /home default directory. I can browse to it through ssh.
    • killer_rabbit
      killer_rabbit almost 6 years
      @JeffSchaller: /abc is not an alias
    • killer_rabbit
      killer_rabbit almost 6 years
      @BowlOfRed: Here is the output I get when running the command you mention: "stdin: is not a tty ls: cannot access /www/abc: No such file or directory"
  • killer_rabbit
    killer_rabbit almost 6 years
    Adding the connection details did the trick! And also one of the paths was not absolute. Thanks a bunch!
  • Kusalananda
    Kusalananda almost 6 years
    Will due respect, but since this anwer doesn't even address the issue of the source directory not being found on the remote host, I'm wondering why it was accepted. The log in on the host works, or else there would not be a chdir error.
  • roaima
    roaima almost 6 years
    1. The directory /www/abc is local so ssh is irrelevant. 2. Your rsync suggestion reverses the data flow to that which the OP wanted. 3. It's also syntactically incorrect for what you have described.
  • Admin
    Admin almost 6 years
    @killer_rabbit Kusulananda's answer is more to the point. You should accept it rather than mine.
  • Admin
    Admin almost 6 years
    @Kusalananda I silently assumed the directories exist, but the paths are incorrect. I should have stated this assumption explicitly. (And present an alternative in case this assertion fails.)