From 767afdb44716815b616b5a829af9e7ae1de7ea2d Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sat, 25 Jan 2020 15:52:22 +0100 Subject: backup.sh: Only create backup-data files when in backup path Signed-off-by: Florian Pritz --- backup.sh | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/backup.sh b/backup.sh index 00431a0..95ce921 100755 --- a/backup.sh +++ b/backup.sh @@ -95,17 +95,19 @@ main() { # This is called before creating the backup pre_backup() { - # save some data that's useful for restores - local backupDataDir=/root/backup-data/ - mkdir -p "$backupDataDir" - fdisk -l > "$backupDataDir/fdisk" - vgdisplay > "$backupDataDir/vgdisplay" - pvdisplay > "$backupDataDir/pvdisplay" - lvdisplay > "$backupDataDir/lvdisplay" - df -a > "$backupDataDir/df" - findmnt -l > "$backupDataDir/findmnt" - mdadm --detail --scan > "$backupDataDir/mdadm" - vgcfgbackup --file "$backupDataDir/vgcfgbackup" + if in_array_startswith '/root/backup-data/' "${source_paths[@]}"; then + # save some data that's useful for restores + local backupDataDir=/root/backup-data/ + mkdir -p "$backupDataDir" + fdisk -l > "$backupDataDir/fdisk" + vgdisplay > "$backupDataDir/vgdisplay" + pvdisplay > "$backupDataDir/pvdisplay" + lvdisplay > "$backupDataDir/lvdisplay" + df -a > "$backupDataDir/df" + findmnt -l > "$backupDataDir/findmnt" + mdadm --detail --scan > "$backupDataDir/mdadm" + vgcfgbackup --file "$backupDataDir/vgcfgbackup" + fi # If you wish to use snapshots, create them here -- cgit v1.2.3-24-g4f1b