diff --git a/backup.py b/backup.py index ed84e0a..1eeb511 100644 --- a/backup.py +++ b/backup.py @@ -102,7 +102,7 @@ def createBackupScriptStructure(backupList, baseDomain=""): os.chmod(os.path.join(backupPath, scriptName), 0o700) # write filter # - filterName = "rsync-filter-{}.txt".format(hostnameBase) + filterName = "rsync-filter-{}-.txt".format(hostnameBase) with open(os.path.join(backupPath, filterName), "w") as f: f.write(rsyncFilterAll) @@ -113,7 +113,7 @@ def createBackupScriptStructure(backupList, baseDomain=""): ( "minimal" , rsyncFilterMinimal ) ] for filterType, render in alternativeRsyncFilters: - filterType = "rsync-filter-{}-{}.txt".format(hostnameBase, filterType) + filterName = "rsync-filter-{}-{}.txt".format(hostnameBase, filterType) with open(os.path.join(backupPath, filterName), "w") as f: f.write(render) diff --git a/templates/rsync-backup.sh.j2 b/templates/rsync-backup.sh.j2 index a80bbba..3dd6c93 100644 --- a/templates/rsync-backup.sh.j2 +++ b/templates/rsync-backup.sh.j2 @@ -4,6 +4,16 @@ set -eu mkdir -p {{ hostname_base }} cd {{ hostname_base }} +TYPE="" +if [ -z "$1" ]; then + TYPE=$1 +fi + +TEST=$(python -c "int('$TYPE' in ['size_changed', 'no_high_data', 'minimal'])^1") +if [ $TEST -ne 0 ]; then + echo Bad Filter Option $1 +fi + dest=./ for x in backup-*; do test -d "$x" || continue @@ -20,7 +30,7 @@ rsync \ --archive --acls --xattrs --hard-links --sparse --numeric-ids \ --one-file-system \ --link-dest="$dest" \ - --filter="merge ../rsync-filter-{{ hostname_base }}.txt" \ + --filter="merge ../rsync-filter-{{ hostname_base }}-${TYPE}.txt" \ root@{{ hostname }}:/ \ "$target_tmp"