전체 경로를 포함하는 Rsync 제외 목록이 있습니까?

전체 경로를 포함하는 Rsync 제외 목록이 있습니까?

제외 매개변수와 함께 rsync를 사용하려고 합니다. 하지만 문제가 있습니다.

처음 생성된 파일 목록이 30분 이상 지났습니다.

find /var/log/hosts/ -type f  -mmin -30 > list.txt

그런 다음 제외와 함께 사용하십시오.

rsync -arvzh --exclude-from 'list.txt'  /var/log/hosts/  [email protected]:/Archive/Rsyslog_Logs/

하지만 모든 파일을 동기화할 수는 없습니다.

list.txt 
/var/log/hosts/p_rsyslog/2021/05/11/14.log
/var/log/hosts/loggerarchive/2021/05/11/14.log
/var/log/hosts/node1/2021/05/11/14.log
/var/log/hosts/node2/2021/05/11/14.log
/var/log/hosts/node3/2021/05/11/14.log
...

답변1

제외 파일의 파일 경로는 전송 루트에 상대적이어야 하므로 /var/log/hosts/경로는 list.txt다음과 같아야 합니다.

/p_rsyslog/2021/05/11/14.log
/loggerarchive/2021/05/11/14.log
/node1/2021/05/11/14.log
/node2/2021/05/11/14.log
/node3/2021/05/11/14.log

이러한 경로는 선행으로 시작하며 /전체 경로로 처리됩니다. 리더가 없으면 /경로의 최종 구성 요소와 일치합니다 node1/2021/05/11/14.log.

/var/log/hosts/node1/2021/05/11/14.log

또한

/var/log/hosts/another_dir/node1/2021/05/11/14.log

이는 바람직하지 않을 수 있습니다.

넌 달릴 수 있어

find /var/log/hosts/ -type f -mmin -30 | sed 's#^/var/log/hosts##' > list.txt

/var/log/hosts제외 파일의 각 줄에서 접두사를 제거합니다.

이 옵션은 -r포함되어 있으므로 명령에서 제거 -a할 수 있습니다 .rsync

관련 정보