rsync exclude를 패턴이 아니게 적용 가능한가요?

ukits의 이미지

rsync를 이용해 서버 2대를 동기화 하려고 합니다.

예를 들어서 log라는 디렉토리를 동기화 하지 않으려고 하면,

# rsync -avz --exclude=log A B

하면 되는데, 디렉토리 구조가

/ --+-- log
     +-- app --+-- log
                    +-- ...

이런식으로 되어있을 때는 app 하위에 있는 logs 디렉토리도 제외 대상에 포함이 되어버리잖아요.
/log 디렉토리는 실제 로그가 있는 반면 /app/log 에는 log와 관련된 로직이 들어있어 동기화 대상이 되어야 하는 경우에는

어떤식으로 rsync 명령을 내려야할까요?

dontdieych의 이미지

--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' 이 두 부분 보시면 설명이 있습니다.

패턴에 / 가 없으면 파일의 이름만 검사하고 / 가 들어가면 경로에도 규칙이 적용 됩니다.

세밀한 사항은 맨페이지 보셔야 합니다.

ukits의 이미지

상대경로를 이용하라는 문구만 보고 앞쪽에 / 를 넣을 생각을 하지 못했네요.
맨페이지 참고해서 더 자세히 알아보겠습니다.

감사합니다!

uki the Sniper

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.