我有几个分区。一个用于安装主操作系统,另一个用作主操作系统备份的目标。我还有一个用于维护的辅助操作系统,上述两个分区分别挂载为 /source 和 /dest。
成功运行后:
sudo rsync -av --del /source /dest
我注意到副本中的 fstab 文件的根分区的 uuid 与原始文件不同,但是,为什么呢?
-a
这和论证等同于-rlptgoD
、-D
存在有关系吗--devices --specials
?
我需要确保我正在执行这个复制操作所要做的事情。
答案1
rsync
不会改变任何文件,因此如果您操作rsync
正确,则应该期望/source/etc/fstab
它与 相同/dest/etc/fstab
。
看起来您的rsync
命令复制到/source
了/dest/source
而不是/dest
您期望的 。因此,如果您检查分区,您可能会发现一个文件/dest/source/etc/fstab
是 的实际副本/source/etc/fstab
(/dest/etc/fstab
恰好与旧数据一起存在)。
/
要按照您想要的方式复制目录,您需要在源中添加尾随(我通常也在目标中添加一个,但我认为这不是必需的),如下所示:
sudo rsync -av --del /source/ /dest/
手册页中的相关文档:
rsync -avz foo:src/bar /data/tmp This would recursively transfer all files from the directory src/bar on the ma‐ chine foo into the /data/tmp/bar directory on the local machine. The files are transferred in "archive" mode, which ensures that symbolic links, devices, at‐ tributes, permissions, ownerships, etc. are preserved in the transfer. Addition‐ ally, compression will be used to reduce the size of data portions of the trans‐ fer. rsync -avz foo:src/bar/ /data/tmp A trailing slash on the source changes this behavior to avoid creating an addi‐ tional directory level at the destination. You can think of a trailing / on a source as meaning "copy the contents of this directory" as opposed to "copy the directory by name", but in both cases the attributes of the containing directory are transferred to the containing directory on the destination. In other words, each of the following commands copies the files in the same way, including their setting of the attributes of /dest/foo: rsync -av /src/foo /dest rsync -av /src/foo/ /dest/foo