【问题标题】:rsync fails to copy /home directoryrsync 无法复制 /home 目录
【发布时间】:2021-10-25 01:39:46
【问题描述】:

我错过了什么?

我有 Ubuntu 20.04.3 LTS,配备 AMD® Ryzen 5 2600 六核处理器 × 12 和 15.6 GiB 内存

和 GNU bash,版本 5.0.17(1)-release-(x86_64-pc-linux-gnu)

我在数组中使用带有参数的 rsync,如下所示:

sudo su
options=( $params$delete$crossfilesystem$excludefile$includefile )
cd /
rsync "${options[@]}" / $target

各种参数正确展开为:

rsync -aAXHv --one-file-system --exclude-from=/home/bill/rsync-excludes / /media/bill/spare

排除的文件如预期的那样为空。但是,/home 也是空的 - 不像预期的那样。

我尝试使用 rsync 而不使用参数,无论是否使用脚本,从根目录或我的主目录开始,都得到相同的结果,/home 中没有任何内容。我没有看到任何错误消息弹出。

root@wrcraig:/# ls -la /media/bill/spare/home
total 8
drwxr-xr-x  2 root root 4096 Apr 18 08:40 .
drwxr-xr-x 26 root root 4096 Aug 23 17:52 ..

但如果我只备份 /home 目录,则使用以下任一目录均可正常工作:

rsync -aAXHv --one-file-system --exclude-from=/home/bill/rsync-excludes /home $target
  or
rsync "${options[@]}" /home $target

这是排除文件(/home/bill/rsync-excludes)

/dev/*
/home/*/.cache/mozilla/*
/home/*/.cache/thunderbird/*
/home/*/.cache/chromium/*
/home/*/.local/share/Trash/*
/proc/*
/sys/*
/tmp/*
/run/*
/mnt/*
/home/*/.gvfs
/var/lib/dhcpcd/*
swap
/var/cache/zoneminder/events/*
/media/*
lost+found

【问题讨论】:

  • df /home 的输出是什么?
  • root:/# df /home Filesystem 1K-blocks Used Available Use% Mounted on /dev/nvme0n1p6 794067928 76672452 676989360 11% /home

标签: backup rsync


【解决方案1】:

您看到这种行为是因为您使用了--one-file-system,但您的/home 目录与/ 是不同的文件系统。

-x, --one-file-system
    This tells rsync to avoid crossing a  filesystem  boundary  when
    recursing.   This  does  not limit the user’s ability to specify
    items to copy from multiple filesystems, just rsync’s  recursion
    through the hierarchy of each directory that the user specified,
    and also the analogous recursion on the  receiving  side  during
    deletion.  Also keep in mind that rsync treats a "bind" mount to
    the same device as being on the same filesystem.

    If this option is repeated, rsync omits all mount-point directo‐
    ries  from  the copy.  Otherwise, it includes an empty directory
    at each mount-point it encounters (using the attributes  of  the
    mounted  directory  because  those of the underlying mount-point
    directory are inaccessible).

【讨论】:

    猜你喜欢
    • 2013-12-16
    • 1970-01-01
    • 1970-01-01
    • 2019-09-03
    • 2019-11-16
    • 1970-01-01
    • 1970-01-01
    • 2011-07-17
    • 2014-02-16
    相关资源
    最近更新 更多