我想将我的 ubuntu 14.04 安装与外部磁盘中的目录同步。
实际上,我是从扩展驱动器启动的,我想在我安装的内部驱动器中制作我的 ubuntu 14.04 发行版的部分副本/media/kenn/c2d1b866/
目标目录挂载在/mnt/RESTORE/backup_14.04.5
我尝试了很多组合同步命令如
sudo rsync -avr /media/kenn/c2d1b866/{bin/,sbin/,usr/,opt/,lib/,var/,etc/,srv/,libx32/,lib64/,run/,boot/,proc/,sys/,dev/} /mnt/RESTORE/backup_14.04.5
sudo rsync -avr /media/kenn/c2d1b866/{bin/,sbin/,usr/,opt/,lib/,var/,etc/,srv/,libx32/,lib64/,run/,boot/,proc/,sys/,dev/} /mnt/RESTORE/backup_14.04.5/
sudo rsync -avr /media/kenn/c2d1b866/{"bin/","sbin/","usr/","opt/","lib/","var/","etc/","srv/","libx32/","lib64/","run/","boot/","proc/","sys/","dev/"} /mnt/RESTORE/backup_14.04.5
以及许多其他,但我失败了,因为括号扩展没有按预期工作。它们将括号目录中的所有文件复制到/mnt/RESTORE/backup_14.04.5
,我的意思是未在 中创建的根目录中backup_14.04.5
我怎样才能复制这些bin/,sbin/,usr/,opt/,lib/,var/,etc/,srv/,libx32/,lib64/,run/,boot/,proc/,sys/,dev/
进入?/media/kenn/c2d1b866/
/mnt/RESTORE/backup_14.04.5
答案1
他们将括号目录中的所有文件复制到
/mnt/RESTORE/backup_14.04.5
这是rsync
源路径末尾有斜杠时的行为/
。来自man rsync
:
A trailing slash on the source changes this behavior to avoid creating
an additional 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.
要复制目录,请忽略/
:
sudo rsync -avr /media/kenn/c2d1b866/{bin,sbin,usr,opt,lib,var,etc,srv,libx32,lib64,run,boot,proc,sys,dev} /mnt/RESTORE/backup_14.04.5