rsync 非 ASCII 字符

rsync 非 ASCII 字符

我正在使用 rsync 备份我的网站文件,使用 --link-dest 从之前的 rsync 备份中进行复制。

rsync -zavx -e 'ssh -p22' \
   --numeric-ids \
   --delete -r \
   --link-dest=../"$latest_backup" "$rhost:$rhost_source" "$local_dest";

我注意到带有非 ASCII 字符的文件看起来已经转换了字符,因此 rsync 正在删除它们,然后重新下载它们。

这是一个例子:

deleting public_html/images/made/96096a4645d59a3e/Moulin_a?\#200_vent_Bourgogne_DBW1901_680_680_s_c1.jpg

public_html/images/made/96096a4645d59a3e/Moulin_à_vent_Bourgogne_DBW1901_1200_801_80.jpg

是否可以阻止 rsync 转换字符?

答案1

需要使用--iconv.

从手册页https://linux.die.net/man/1/rsync

--iconv=CONVERT_SPEC 
 Rsync can convert filenames between character sets using this option. 
 Using a CONVERT_SPEC of lq.rq tells rsync to
 look up the default character-set via the locale setting. Alternately,
 you can fully specify what conversion to do by giving a local and a
 remote charset separated by a comma in the order --iconv=LOCAL,REMOTE,
 e.g. --iconv=utf8,iso88591. This order ensures that the option will
 stay the same whether you're pushing or pulling files. Finally, you
 can specify either --no-iconv or a CONVERT_SPEC of lq-rq to turn off
 any conversion. The default setting of this option is site-specific,
 and can also be affected via the RSYNC_ICONV environment variable.

相关内容