2013-07-16 13 views
5

Chciałbym, aby rsync wykluczył wszystkie katalogi zawierające plik o określonej nazwie, powiedz ".rsync-exclude", niezależnie od zawartości ".rsync -exclude "plik.Niech rsync wyklucza wszystkie katalogi zawierające plik o konkretnej nazwie

Jeśli plik „.rsync wykluczeń” zawierała tylko «*», mogłem użyć rsync -r SRC DEST --filter='dir-merge,- .rsync-exclude'.

Należy jednak wykluczyć katalog, niezależnie od zawartości pliku ".rsync-exclude" (powinno być co najmniej możliwe pozostawienie pustego pliku ".ynync-exclude").

Wszelkie pomysły?

Odpowiedz

4

rsync nie obsługuje tego (przynajmniej podręcznika nie wspomina nic), ale można to zrobić w dwóch etapach:

  1. run find wybrać .rsync-exclude pliki
  2. rurę tę listę --exclude-from (lub użycie tymczasowej plik)

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

Alternatywnie, jeżeli nie przeszkadza, aby umieścić coś w plikach, można użyć:

 -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

Stare pytanie, ale miałem ten sam jeden ..

Możesz dodać następujący filtr:

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

Teraz możesz umieścić plik .rsync-exclude w dowolnym folderze i wpisać nazwy plików i folderów, które chcesz wykluczyć linia po linii. na przykład:

#.rsync-exclude file 

folderYouWantToExclude 
allFilesThatStartWithXY* 
someSpecialImage.png 

Możesz tam również użyć wzorów.

Czego nie może zrobić, to:

#.rsync-exclude file 

folder/someFileYouWantToExlude 

Nadzieję, że to pomaga! Pozdrowienia

Powiązane problemy