rsync: 최상위 디렉토리를 제외하는 방법

rsync: 최상위 디렉토리를 제외하는 방법

따라서 겉으로는 간단한 문제가 있지만 지금까지 해결책을 찾지 못했습니다. rsync에서 최상위 디렉토리를 제외하고 모든 하위 디렉토리를 계속 동기화하고 싶습니다. 특별한 문제는 최상위 디렉토리의 시간을 수정할 권한이 없지만 모든 하위 디렉토리의 시간이 적절하게 동기화되기를 원한다는 것입니다.

내가 사용하는 rsync 명령은 다음과 같습니다.

rsync --exclude ./ -rlptDu ./ server.example.com:/usr/local/directory/

다음 과 server.example.com:/usr/local/directory/같이 보입니다.

drwxrws---  5 root   staff 24576 Jul  9 15:00 .

(내 로컬 사용자는 의 회원입니다 staff)

rsync를 실행하면 다음 오류가 발생합니다.

rsync: failed to set times on "/usr/local/directory/.": Operation not permitted (1)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1070) [sender=3.0.9]
make: *** [pub_to_mel_internal] Error 23

로컬 컴퓨터의 버전은 3.0.9이고 원격 컴퓨터의 경우 3.0.7입니다. 두 컴퓨터 모두 Debian을 실행합니다.

답변1

rsync의 필터 규칙은 최상위 디렉토리와 일치하지 않으므로 항상 동기화되는 것 같습니다. 해결 방법은 디렉터리 자체 대신 이 디렉터리 내의 모든 파일을 동기화하는 것입니다.

rsync -rlptDu -- * server.example.com:/usr/local/directory/

최상위 디렉토리에 도트 파일이 있고 파일 이름이 두 개의 도트로 시작하는 경우 .[!.]*뒤에 추가하십시오 .*..?*

답변2

rsync는 다음을 사용하여 최상위 디렉토리를 제외할 수 있는 것 같습니다 --files-from.

$ rsync -anv from/ to/
sending incremental file list
./
a
b.test

sent 97 bytes  received 25 bytes  244.00 bytes/sec
total size is 0  speedup is 0.00 (DRY RUN)
$ printf '%s\n' 'a' 'b.test' | rsync -anv --files-from=- from/ to/
building file list ... done
a
b.test

sent 88 bytes  received 22 bytes  220.00 bytes/sec
total size is 0  speedup is 0.00 (DRY RUN)

우연히 발견한 내용이 누군가(또는 미래의 나)에게 도움이 될 경우를 대비해 여기에 단서를 남겨둡니다.

관련 정보