到Amazon Linux EC2实例的Rsync - 失败:没有这样的文件或目录

时间:2023-01-26 12:55:58

I want to upload the content of one directory to my Amazon EC2 with rsync:

我想用rsync将一个目录的内容上传到我的Amazon EC2:

rsync -r -t -v --progress -z -s -e "ssh -i /home/mostafa/keyamazon.pem" /home/mostafa/splitfiles ubuntu@ec2-64-274-161-87.compute-1.amazonaws.com:~/splitfiles

but I receive the following error message:

但是我收到以下错误消息:

sending incremental file list
rsync: link_stat "/home/mostafa/splitfiles" failed: No such file or directory (2)
rsync: change_dir#3 "/home/ubuntu//~" failed: No such file or directory (2)
rsync error: errors selecting input/output files, dirs (code 3) at main.c(712) [Receiver=3.1.0]

and if I do a dry run with grsync, it works correctly

如果我使用grsync进行干运行,它可以正常工作

3 个解决方案

#1


0  

In rsync the trailing / is very important. Also you rsync usually defaults to ssh when one of the destinations contains a host.

在rsync中,尾随/非常重要。此外,当其中一个目标包含主机时,rsync通常默认为ssh。

So you if you want to preserver modification times then you can get rid of the -e and -s options.

因此,如果您想要保留修改时间,那么您可以摆脱-e和-s选项。

Your command could be written as /home/mostafa/splitfiles/ ubuntu@ec2-64-274-161-87.compute-1.amazonaws.com:splitfiles/ - notice the trailing /'s provided that you have ssh configured to read the private key from your home directory.

你的命令可以写成/ home / mostafa / splitfiles / ubuntu@ec2-64-274-161-87.compute-1.amazonaws.com:splitfiles / - 注意你有ssh配置为读取的尾随/主目录中的私钥。

On ubuntu you can add this to the key chain, by going

在ubuntu上,您可以将其添加到密钥链中

ssh-add [key-file]

And this will save you having to specify the keyfile everytime you ssh into the AWS machine.

这将节省您每次进入AWS机器时都必须指定密钥文件。

The errors seem to say that on the local machine you don't have a source directory and the destination doesn't exist.

错误似乎表明,在本地计算机上,您没有源目录,并且目标不存在。

#2


0  

I completed this task with Filezilla instead, easier to use.

我用Filezilla完成了这项任务,更容易使用。

#3


0  

You are at home ~ if you cd ../ to root you will be able to run the command.

你在家〜如果你cd ../到root你就可以运行命令了。

#1


0  

In rsync the trailing / is very important. Also you rsync usually defaults to ssh when one of the destinations contains a host.

在rsync中,尾随/非常重要。此外,当其中一个目标包含主机时,rsync通常默认为ssh。

So you if you want to preserver modification times then you can get rid of the -e and -s options.

因此,如果您想要保留修改时间,那么您可以摆脱-e和-s选项。

Your command could be written as /home/mostafa/splitfiles/ ubuntu@ec2-64-274-161-87.compute-1.amazonaws.com:splitfiles/ - notice the trailing /'s provided that you have ssh configured to read the private key from your home directory.

你的命令可以写成/ home / mostafa / splitfiles / ubuntu@ec2-64-274-161-87.compute-1.amazonaws.com:splitfiles / - 注意你有ssh配置为读取的尾随/主目录中的私钥。

On ubuntu you can add this to the key chain, by going

在ubuntu上,您可以将其添加到密钥链中

ssh-add [key-file]

And this will save you having to specify the keyfile everytime you ssh into the AWS machine.

这将节省您每次进入AWS机器时都必须指定密钥文件。

The errors seem to say that on the local machine you don't have a source directory and the destination doesn't exist.

错误似乎表明,在本地计算机上,您没有源目录,并且目标不存在。

#2


0  

I completed this task with Filezilla instead, easier to use.

我用Filezilla完成了这项任务,更容易使用。

#3


0  

You are at home ~ if you cd ../ to root you will be able to run the command.

你在家〜如果你cd ../到root你就可以运行命令了。