AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题 / 533690
Accepted
Nick The Swede
Nick The Swede
Asked: 2014-10-09 07:39:54 +0800 CST2014-10-09 07:39:54 +0800 CST 2014-10-09 07:39:54 +0800 CST

带有特殊字符文件的 Rsync 在 Mac 和 Linux 之间不起作用

  • 772

我想使用 rsync 通过驻留在 Mac 上的磁盘备份我的 Ubuntu 服务器。但是我没有让它正常工作,因为每次我在初始时间后重新运行 rsync 操作时,带有特殊字符的文件都会先被删除然后重新同步。好像是不同字符集的问题。

首选解决方案似乎是使用该选项--iconv:

您可以使用 rsync 的 --iconv 选项在 UTF-8 NFC 和 NFD 之间进行转换,至少如果您使用的是 Mac。有一个特殊的 utf-8-mac 字符集,代表 UTF-8 NFD。因此,要将文件从 Mac 复制到 NAS,您需要运行如下命令:

rsync -a --iconv=utf-8-mac,utf-8 localdir/ mynas:remotedir/

这会将所有本地文件名从 UTF-8 NFD 转换为远程服务器上的 UTF-8 NFC。文件的内容不会受到影响。

感谢@Jan,我从 2.6.9更新了 mac 上的 rsync 版本。至 3.1.1。尽管如此,我仍然不在那里,因为我现在收到另一个错误:

iconv_open("UTF-8", "utf-8-mac") failed
rsync error: requested action not supported (code 4) at rsync.c(118) [sender=3.0.9]
rsync: connection unexpectedly closed (0 bytes received so far) [Receiver]
rsync error: error in rsync protocol data stream (code 12) at io.c(226) [Receiver=3.1.1]

我不明白为什么“不支持请求的操作”,因为我的 Ubuntu (12.04) 上的 rsync 版本似乎是 3.xx 之后的版本,因此应该支持该--iconv选项。

编辑:让我补充一点,当我(在 Mac 上,nota bene)启动从 Mac 到 Linux 的 rsync 时,一切都运行良好:

rsync -av --delete --iconv=utf-8-mac,utf-8 localdir/ mynas:remotedir/

但是从 mac 走另一条路是行不通的。奇怪的是,测试从 linux 机器启动 rsync 会呈现这个奇怪的消息:

rsync: on remote machine: --iconv=UTF-8-MAC: unknown option
rsync error: syntax or usage error (code 1) at /SourceCache/rsync/rsync-45/rsync/main.c(1333) [server=2.6.9]
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(605) [sender=3.0.9]

包括非常奇怪的说法[server=2.6.9],虽然我已经在 Mac 上更新到 3.1.1。由于某些原因,我的 linux 机器看起来只“看到”Mac 上的原始 rsync 版本。

关于如何解决这个问题的任何建议?

12.04
  • 2 2 个回答
  • 30302 Views

2 个回答

  • Voted
  1. Best Answer
    Nick The Swede
    2014-10-25T03:13:08+08:002014-10-25T03:13:08+08:00

    解决方案非常简单:很大程度上是由于我在研究该问题时阅读的评论,我认为您应该按照转换顺序指定字符集;但似乎这不是正确的语法。相反,无论我想从 mac 还是 linux 机器同步文件,都应该在从 mac 初始化 rsync 时始终使用,并且在从linux 机器初始化 rsync 时始终使用。--iconv=utf-8-mac,utf-8--iconv=utf-8,utf-8-mac

    然后它就像魔术一样工作!

    编辑:确实,有时候,仔细检查手册页是一件好事。在这里,黑底白字:

    --iconv=CONVERT_SPEC
                  Rsync  can  convert  filenames between character sets using this
                  option.  Using a CONVERT_SPEC of "." 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 push-
                  ing  or  pulling  files.
    
    • 29
  2. vandit6354
    2017-08-27T23:47:25+08:002017-08-27T23:47:25+08:00

    我可以确认这有效,我遇到了同样的问题。在我的例子中,任何带有重音字符的文件在目的地都是不可读的。我只是通过使用比较文件夹应用程序在我的 Mac 上运行文件夹比较才发现它: https ://itunes.apple.com/gb/app/compare-folders/id816042486?mt=12

    添加了上面的 --iconv=utf-8-mac,utf-8 和 BOOM! rsync 用一个新文件替换了每个重音文件。

    要添加一些信息,因为上面的链接似乎不再有效,要将 rsync 升级到 3.1.2,安装 Macports 并运行:sudo port install rsync

    您看到远程服务器返回版本 2.6.9 的原因是因为旧版本实际上仍然存在并且远程服务器看到的是那个版本而不是新版本。

    版本 2.6.9 位于 /usr/bin

    • 4

相关问题

  • 跨(全屏)应用程序拖放,通过 Alt-Tab 切换

  • Guake 终端在 Unity 中显示错误

  • 字体损坏:通过字符的行

  • 使用活动应用程序自动切换到工作区

  • 如何查看实际内存及其属性(插槽位置、大小、速度...)

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve