rsync 중괄호 확장 통찰력

rsync 중괄호 확장 통찰력

내 우분투 14.04 설치를 외부 디스크의 디렉터리와 동기화하고 싶습니다.

실제로 확장 드라이브에서 부팅했고 내가 마운트한 내부 드라이브에 우분투 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

관련 정보