2013-07-16 15 views
5

Desidero che rsync escluda tutte le directory che contengono un file con un nome specifico, ad esempio ".rsync-exclude", indipendente dal contenuto di ".rsync -exclude "file.Rsync esclude tutte le directory che contengono un file con un nome specifico

Se il file ".rsync-exclude" conteneva solo "*", potrei usare rsync -r SRC DEST --filter='dir-merge,- .rsync-exclude'.

Tuttavia, la directory deve essere esclusa indipendentemente dal contenuto del file ".rsync-exclude" (dovrebbe essere almeno possibile lasciare il file ".rsync-exclude" vuoto).

Qualche idea?

risposta

4

rsync non supporta questa (almeno la pagina di manuale non menziona nulla), ma è possibile farlo in due fasi:

  1. run find per trovare i file .rsync-exclude
  2. tubo di questa lista per --exclude-from (o utilizzare un file temporaneo)

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

in alternativa, se non vi occupate di mettere qualcosa nei file, è possibile utilizzare:

 -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

vecchia questione, ma ho avuto lo stesso ..

È possibile aggiungere il seguente filtro:

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

Ora puoi inserire un file .rsync-exclude in qualsiasi cartella e scrivere i nomi dei file e delle cartelle che vuoi escludere linea per linea. per esempio:

#.rsync-exclude file 

folderYouWantToExclude 
allFilesThatStartWithXY* 
someSpecialImage.png 

modo da poter utilizzare i modelli anche lì.

Quello che non si può fare è:

#.rsync-exclude file 

folder/someFileYouWantToExlude 

Speranza che aiuta! Saluti

Problemi correlati