diff --git a/tasks/main.yml b/tasks/main.yml index 52280de..4b2b0ca 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -17,6 +17,12 @@ mode: "0400" changed_when: "true" # we always want ti give roles a chance to register dirs +- name: create the /backup-dirs-exclude file + file: + path: "/backup-dirs-exlude" + state: "touch" + mode: "0400" + - name: Ensure file contains lines from array # this also runs on main in case someone doesn't run the backup.yml lineinfile: path: /backup-dirs diff --git a/templates/backup-send.sh.j2 b/templates/backup-send.sh.j2 index 7c6e537..7f56f7a 100644 --- a/templates/backup-send.sh.j2 +++ b/templates/backup-send.sh.j2 @@ -8,7 +8,10 @@ $RESTIC --password-file=$PWD_FILE unlock date echo "Sending the backup to the destination..." -cat /backup-dirs | xargs -d '\n' $RESTIC --password-file=$PWD_FILE backup +{ + cat /backup-dirs + sed -e '/^$/d' -e 's|^|--exclude=|' /backup-dirs-exclude +} | xargs -d '\n' $RESTIC --password-file=$PWD_FILE backup date echo "Pruning the backup on the destination..."