我一直在尝试以下命令:
rsync -rvz --progress --remove-sent-files ./dir user@host:2222/path
Run Code Online (Sandbox Code Playgroud)
SSH在端口2222上运行,但是rsync仍然尝试使用端口22然后抱怨没有找到路径,因为它当然不存在.
我想知道是否可以rsync到非标准ssh端口上的远程主机.
有关设置Ghost博客的文章说使用scp
从本地计算机复制到远程服务器:
scp -r ghost-0.3 root@*your-server-ip*:~/
Run Code Online (Sandbox Code Playgroud)
但是,Railscast 339:Chef Solo Basics用于scp
向相反方向复制(从远程服务器到本地机器):
scp -r root@178.xxx.xxx.xxx:/var/chef .
Run Code Online (Sandbox Code Playgroud)
在相同的Railscast中,当作者想要将文件复制到远程服务器时(与第一个示例相同),他使用rsync
:
rsync -r . root@178.xxx.xxx.xxx:/var/chef
Run Code Online (Sandbox Code Playgroud)
rsync
如果scp
要在两个方向上复制,为什么要使用该命令?有scp
什么不同rsync
?
我从rsync中得到一个令人困惑的错误,我从网络搜索中找到的最初的东西(以及所有通常的chmod'ing)都没有解决它:
rsync: failed to set times on "/foo/bar": Operation not permitted (1)
rsync error: some files could not be transferred (code 23)
at /SourceCache/rsync/rsync-35.2/rsync/main.c(992) [sender=2.6.9]
Run Code Online (Sandbox Code Playgroud)
尽管有这样的错误,它似乎仍在工作,但摆脱它会很好.
我有两台机器,速度和质量.speed具有快速的Internet连接,并且正在运行将大量文件下载到磁盘的爬虫.质量有很多磁盘空间.我想在下载完成后将文件从速度移动到质量.理想情况下,我只是运行:
$ rsync --remove-source-files speed:/var/crawldir .
Run Code Online (Sandbox Code Playgroud)
但我担心rsync会取消尚未完成下载的源文件的链接.(我查看了源代码,但我没有看到任何可以防止这种情况的内容.)有什么建议吗?
我想rsync
从本地计算机到服务器.在不存在的rsync
目录上,我想首先在服务器上创建该目录.
我怎样才能做到这一点?
这是我认为我应该使用rsync使用身份文件进行连接的语法:
rsync -avz -e 'ssh -p1234 -i ~/.ssh/1234-identity' \ "/local/dir/" remoteUser@22.33.44.55:"/remote/dir/"
但它给了我一个错误:
Warning: Identity file ~/.ssh/1234-identity not accessible: No such file or directory.
文件很好,权限设置正确,它在执行ssh时工作 - 只是不使用rsync - 至少在我的语法中.我究竟做错了什么?它是否试图在远程计算机上查找身份文件?如果是这样,我如何指定我想在本地计算机上使用身份文件?
我正在尝试使用不同的名称同步两个文件夹内容:
rsync -av ~/foo user@remote.com:/var/www/bar
Run Code Online (Sandbox Code Playgroud)
我想将内容复制foo
到bar
远程主机,但不是目录foo
本身.我尝试了类似的东西foo/*
,但rsync不支持.
rsync始终创建
/var/www/bar/foo
Run Code Online (Sandbox Code Playgroud) 我试图了解两个选项之间的区别
rsync --size-only
Run Code Online (Sandbox Code Playgroud)
和
rsync --ignore-times
Run Code Online (Sandbox Code Playgroud)
我的理解是,默认情况下,rsync将比较时间戳和文件大小,以决定是否应同步文件.上面的选项允许用户影响此行为.
两种选择似乎都至少在口头上导致同样的事情:仅按大小进行比较.
我错过了一些微妙的东西吗?