rsync exclude를 패턴이 아니게 적용 가능한가요?
글쓴이: ukits / 작성시간: 화, 2014/02/11 - 8:24오후
rsync를 이용해 서버 2대를 동기화 하려고 합니다.
예를 들어서 log라는 디렉토리를 동기화 하지 않으려고 하면,
# rsync -avz --exclude=log A B
하면 되는데, 디렉토리 구조가
/ --+-- log
+-- app --+-- log
+-- ...
이런식으로 되어있을 때는 app 하위에 있는 logs 디렉토리도 제외 대상에 포함이 되어버리잖아요.
/log 디렉토리는 실제 로그가 있는 반면 /app/log 에는 log와 관련된 로직이 들어있어 동기화 대상이 되어야 하는 경우에는
어떤식으로 rsync 명령을 내려야할까요?
Forums:


--exclude=/log 이렇게 해보세요. ➜
--exclude=/log
이렇게 해보세요.
➜ tmp tree a a 0 directories, 0 files ➜ tmp tree b b ├── app │ └── log ├── log └── ss └── log 5 directories, 0 files ➜ tmp rsync -avs b a -ni --exclude=log sending incremental file list cd+++++++++ b/ cd+++++++++ b/app/ cd+++++++++ b/ss/ sent 129 bytes received 28 bytes 314.00 bytes/sec total size is 0 speedup is 0.00 (DRY RUN) ➜ tmp rsync -avs b a -ni --exclude=/b/log sending incremental file list cd+++++++++ b/ cd+++++++++ b/app/ cd+++++++++ b/app/log/ cd+++++++++ b/ss/ cd+++++++++ b/ss/log/ sent 185 bytes received 36 bytes 442.00 bytes/sec total size is 0 speedup is 0.00 (DRY RUN) ➜ tmp rsync -avs b a -ni sending incremental file list cd+++++++++ b/ cd+++++++++ b/app/ cd+++++++++ b/app/log/ cd+++++++++ b/log/ cd+++++++++ b/ss/ cd+++++++++ b/ss/log/ sent 207 bytes received 40 bytes 494.00 bytes/sec total size is 0 speedup is 0.00 (DRY RUN)맨페이지에서 'INCLUDE/EXCLUDE PATTERN RULES', 'ANCHORING INCLUDE/EXCLUDE PATTERNS' 이 두 부분 보시면 설명이 있습니다.
패턴에 / 가 없으면 파일의 이름만 검사하고 / 가 들어가면 경로에도 규칙이 적용 됩니다.
세밀한 사항은 맨페이지 보셔야 합니다.
감사합니다.
상대경로를 이용하라는 문구만 보고 앞쪽에 / 를 넣을 생각을 하지 못했네요.
맨페이지 참고해서 더 자세히 알아보겠습니다.
감사합니다!
uki the Sniper
댓글 달기