Excludes by variables

ojaksch

Renowned Member
Oct 11, 2015
204
47
93
Germany/Earth
I'm playing around with proxmox-backup-client and (bash) scripts. Everything works great so far, including "fixed" --excludes parameters.
Working example:
Code:
BACKUPNAME="AllWithoutHome"
mount /dev/sda1 /mnt -o ro,noatime
proxmox-backup-client backup ${BACKUPNAME}.pxar:/mnt --backup-id ${BACKUPNAME} --all-file-systems --skip-lost-and-found --verbose true --exclude '/home/user/*'
umount /mnt

Non-working example:
Code:
BACKUPNAME="AllWithoutHome"
EXCL="--exclude '/home/user/*'"
mount /dev/sda1 /mnt -o ro,noatime
proxmox-backup-client backup ${BACKUPNAME}.pxar:/mnt --backup-id ${BACKUPNAME} --all-file-systems --skip-lost-and-found --verbose true ${EXCL}
umount /mnt

Even non-working example:
Code:
BACKUPNAME="AllWithoutHome"
EXCL="'/home/user/*'"
mount /dev/sda1 /mnt -o ro,noatime
proxmox-backup-client backup ${BACKUPNAME}.pxar:/mnt --backup-id ${BACKUPNAME} --all-file-systems --skip-lost-and-found --verbose true --exclude ${EXCL}
umount /mnt

So what's the point I'm missing here by using variables for excludes?
 
Last edited:
Oooh, I love that to help myself while complaing :) The secret is to omit the single quotes in variables.

Now working example:
Code:
BACKUPNAME="AllWithoutHome"
EXCL="--exclude /home/user/*"
mount /dev/sda1 /mnt -o ro,noatime
proxmox-backup-client backup ${BACKUPNAME}.pxar:/mnt --backup-id ${BACKUPNAME} --all-file-systems --skip-lost-and-found --verbose true ${EXCL}
umount /mnt

But the next thing I'm trying and failing is the exclude vice versa, to exclude everything but a subfolder. I'm using --exclude '/*' --exclude '!/home/user/*' as stated in the documentation (page 55) but that doesn't work.