Support for excluding backup dirs

This commit is contained in:
Kuba Orlik 2026-11-09 18:54:21 +01:00
parent 2593340346
commit 696032b568
2 changed files with 10 additions and 1 deletions

View File

@ -17,6 +17,12 @@
mode: "0400" mode: "0400"
changed_when: "true" # we always want ti give roles a chance to register dirs 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 - name: Ensure file contains lines from array # this also runs on main in case someone doesn't run the backup.yml
lineinfile: lineinfile:
path: /backup-dirs path: /backup-dirs

View File

@ -8,7 +8,10 @@ $RESTIC --password-file=$PWD_FILE unlock
date date
echo "Sending the backup to the destination..." 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 date
echo "Pruning the backup on the destination..." echo "Pruning the backup on the destination..."