Hallo!
Ich möchte mit rsync nur Odner zum Ziel synchronisieren, die aus 8 Zahlen bestehen und nur PDF-Dateien. Mit dem folgenden Skript haut es zwar hin, dass alles wunschgemäß zum Ziel kopiert wird. Lösche ich aber Dateien und/oder Ordner, so werden diese nicht am Ziel gelöscht.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # debug var, set true for console msg debug=false # vars, change if needed basepath=/root/temp/quelle/ target=/root/temp/ziel/ IncExFiles=/root/temp/ # don't change ! includeFiles="${IncExFiles}includeFiles" excludeFiles="${IncExFiles}excludeFiles" # switch to base path cd $basepath # find files to include (only dirs with 8 digits) and all PDF files find . -type f -regextype sed -regex '.*/[0-9]\{8\}/.*\.pdf' | cut -sd / -f 2- > $includeFiles # find files to exclude (no folder with archiv in it's name!) find . -type f -regextype sed -regex '.*[Aa]rchiv.*' | cut -sd / -f 2- > $excludeFiles # copy files to target rsync -azsb --iconv='UTF-8' --delete --backup-dir=/root/temp/backup --exclude-from=$excludeFiles --files-from=$includeFiles $basepath $target |
Wie muss ich das Skript anpassen?
Bearbeitet von tuxifreund:
Aus dem Spamfilter gefischt
Moderiert von sebix:
Thema in einen passenden Forenbereich verschoben. Bitte beachte die als wichtig markierten Themen („Welche Themen gehören hier her und welche nicht?“) in jedem Forenbereich. Danke.