rsync 不适用于包含白色 space 的变量

rsync not working with variable containing a white space

如果源或目标变量在文件夹名称

中有 space,我无法让我的 rsync 脚本工作
#!/bin/bash
HOST="root@192.168.1.100"
source="/path/My Files/"
dest="/path/My Files2/"

rsync -avhP --delete "$HOST":"$source" "$dest"

我得到的错误是

receiving incremental file list
rsync: [sender] link_stat "/path/My" failed: No such file or directory (2)
rsync: [sender] change_dir "/root/Files" failed: No such file or directory (2)

任何帮助如何写这将是伟大的

使用当前 rsync 版本添加选项 -s

来自man rsync

-s, --protect-args: This option sends all filenames and most options to the remote rsync without allowing the remote shell to interpret them. This means that spaces are not split in names, and any non-wildcard special characters are not translated (such as ~, $, ;, &, etc.). Wildcards are expanded on the remote host by rsync (instead of the shell doing it).