【问题标题】:Why is rsync so slow?为什么 rsync 这么慢?
【发布时间】:2016-07-10 16:00:50
【问题描述】:

我使用 rsync 在我的笔记本电脑和外部 USB 驱动器之间备份一个 60G 的文件夹。只添加了4G的数据。花了很长时间才完成:2小时。

命令如下:

rsync -av --exclude=target/ --exclude=".git/" --delete --link-dest=$destdir/backup.1 $element $destdir/backup.0

你有解释吗? 是什么让 rsync 更慢:很多小文件或大二进制文件(照片)?

【问题讨论】:

    标签: rsync


    【解决方案1】:

    由于我不完全了解您的系统,因此我在这里做一些假设。如果它们与您的情况不符,请澄清您的问题,我会很乐意更新我的答案。

    我假设您有很多文件,无论它们在您从中复制的位置有多大。这会导致rsync协议的设计导致rsync比较慢。

    rsync 是这样工作的:

    1. Build a file-list of the source location.
    
    2. For all files in the source location:
    
      a. Get the size and the mtime (modification timestamp)
      b. Compare it with the size and mtime of the copy in the destination location
      c. If they differ, copy the file from the source to the destination
    
    Done.
    

    如果你只有几个文件,这显然会比很多文件更快。您的 USB 驱动器可能是您的瓶颈,因为检索大小和时间戳会在 inode 表中产生大量跳转。

    也许像 iotop 这样的工具(如果您在 Linux 上,几乎所有平台都可以使用类似的工具)可以帮助您识别瓶颈。

    --delete 选项也可能导致慢速 rsync,如果检索目标位置的完整文件列表很慢(这可能是外部旋转 USB 磁盘)。要验证这是否是问题所在,在任何带有 bash 的操作系统上,只需键入 time ls -Ral <target-location> > filelist.txt(将输出转移到文件,因为在屏幕上输出数据要慢得多)。如果这比您的源磁盘花费的时间长很多,那么您的目标磁盘可能是瓶颈。

    【讨论】:

      猜你喜欢
      • 2021-09-03
      • 2016-09-28
      • 2020-02-08
      • 2012-07-17
      • 2011-11-07
      • 2015-08-24
      • 2013-08-06
      • 2014-07-16
      • 2011-01-02
      相关资源
      最近更新 更多