
我想將我的 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