rsync 无法复制 /home 目录

rsync fails to copy /home directory

我错过了什么?

我有 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

您看到此行为是因为您使用了 --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).