rsync 到远程目录

Ali*_*ice 2 ssh rsync

我尝试将主目录更新为备份计算机

rsync -avru --exclude-from='/home/me/exclude-me.txt' /home/me/* assistant@assistant.local:/home/assistant/* -p 2222
Run Code Online (Sandbox Code Playgroud)

但得到一个错误

Unexpected remote arg: assistant@assistant.local:
rsync error: syntax or usage error (code 1) at main.c(1361) [sender=3.1.2]
Run Code Online (Sandbox Code Playgroud)

我的代码有什么问题?

Tho*_*mas 6

对于rsync-p选项表示保留权限,并且不带参数。因此您的命令无法正确解析,您会收到错误消息。

如果要更改rsync应该连接的 SSH 端口,请使用以下命令。

rsync -avru --exclude-from='/home/me/exclude-me.txt' -e 'ssh -p 2222' \ 
/home/me/ \
assistant@assistant.local:/home/assistant/
Run Code Online (Sandbox Code Playgroud)