2013-07-16 12 views
5

है, मैं उन सभी निर्देशिकाओं को बाहर करने के लिए rsync चाहता हूं जिनमें एक विशिष्ट नाम वाली फ़ाइल शामिल है, ".rsync-extrae" कहें, ".rsync की सामग्री से स्वतंत्र फ़ाइल को छोड़ दें।rsync को उन सभी निर्देशिकाओं को बाहर निकालें जिनमें एक विशिष्ट नाम

यदि फ़ाइल ".rsync-extrae" में केवल "*" है, तो मैं rsync -r SRC DEST --filter='dir-merge,- .rsync-exclude' का उपयोग कर सकता हूं।

हालांकि, निर्देशिका को ".rsync-extrae" फ़ाइल की सामग्री से स्वतंत्र किया जाना चाहिए (कम से कम ".rsync-extrae" फ़ाइल को खाली छोड़ना संभव है)।

कोई विचार?

उत्तर

4

rsync इस का समर्थन नहीं करता (कम से कम मैनपेज कुछ भी उल्लेख नहीं है), लेकिन आप दो चरणों में यह कर सकते हैं:

  1. रन find.rsync-exclude फ़ाइलों
  2. पाइप के लिए इस सूची को खोजने के लिए --exclude-from (या एक अस्थायी फ़ाइल)

    --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. 
    

वैकल्पिक रूप से, अगर आप फाइलों में कुछ डाल करने के लिए कोई आपत्ति नहीं है, तो आप उपयोग कर सकते हैं:

 -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

पुराना सवाल है, लेकिन मैं एक ही एक ..

आप निम्न फिल्टर जोड़ सकते हैं था:

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

अब आप किसी भी फ़ोल्डर में .rsync-exte फ़ाइल डाल सकते हैं और उन फ़ाइलों और फ़ोल्डरों के नाम लिख सकते हैं जिन्हें आप लाइन से लाइन को बाहर करना चाहते हैं। उदाहरण के लिए:

#.rsync-exclude file 

folderYouWantToExclude 
allFilesThatStartWithXY* 
someSpecialImage.png 

तो आप वहां भी पैटर्न का उपयोग कर सकते हैं।

क्या आप ऐसा नहीं कर सकते है:

#.rsync-exclude file 

folder/someFileYouWantToExlude 

आशा है कि यह मदद करता है! चीयर्स

संबंधित मुद्दे