2013-07-16 39 views
5

Tôi muốn rsync loại trừ tất cả các thư mục chứa tệp có tên cụ thể, nói ".sync-exclude", độc lập với nội dung của ".rsync -exclude "tập tin.Làm cho rsync loại trừ tất cả các thư mục chứa tệp có tên cụ thể

Nếu tệp ".rsync-exclude" chỉ chứa "*", tôi có thể sử dụng rsync -r SRC DEST --filter='dir-merge,- .rsync-exclude'.

Tuy nhiên, thư mục phải được loại trừ độc lập với nội dung của tệp ".yncync-exclude" (ít nhất cũng nên để tệp ".yncync-exclude" trống).

Bất kỳ ý tưởng nào?

Trả lời

4

rsync không hỗ trợ này (ít nhất là manpage không đề cập đến bất cứ điều gì), nhưng bạn có thể làm điều đó trong hai bước:

  1. chạy find để tìm .rsync-exclude file
  2. ống danh sách này để --exclude-from (hoặc sử dụng một tập tin tạm thời)

    --exclude-from=FILE 
         This option is related to the --exclude option, but it specifies a FILE that contains exclude patterns 
         (one per line). Blank lines in the file and lines starting with ';' or '#' are ignored. If FILE is -, 
         the list will be read from standard input. 
    

cách khác, nếu bạn không nhớ để đặt một cái gì đó trong các tập tin, bạn có thể sử dụng:

 -F  The -F option is a shorthand for adding two --filter rules to your command. The first time it is used 
      is a shorthand for this rule: 

      --filter='dir-merge /.rsync-filter' 

      This tells rsync to look for per-directory .rsync-filter files that have been sprinkled through the 
      hierarchy and use their rules to filter the files in the transfer. If -F is repeated, it is a short- 
      hand for this rule: 

      --filter='exclude .rsync-filter' 

      This filters out the .rsync-filter files themselves from the transfer. 

      See the FILTER RULES section for detailed information on how these options work. 
4

Cũ câu hỏi, nhưng tôi đã có cùng một ..

Bạn có thể thêm bộ lọc sau:

--filter="dir-merge,n- .rsync-exclude" 

Bây giờ bạn có thể đặt tệp .rsync-exclude vào bất kỳ thư mục nào và viết tên của các tệp và thư mục bạn muốn loại trừ từng dòng. ví dụ:

#.rsync-exclude file 

folderYouWantToExclude 
allFilesThatStartWithXY* 
someSpecialImage.png 

Vì vậy, bạn cũng có thể sử dụng các mẫu trong đó.

gì bạn không thể làm là:

#.rsync-exclude file 

folder/someFileYouWantToExlude 

Hy vọng nó sẽ giúp! Chúc mừng

Các vấn đề liên quan