If backupdir key is missing, use root dir to mounted disk

The user can hit enter when creating a new directory (no directory is
created). In doing so "backupdir" is set to nothing. Snapper does not
keep that key. Upon a search of the latest incremental backup we didn't
check for backupdir, we just had taken the first key (which ended up
being the UUID ). We now check for the backupdir key, and if it is
missing that means use the root directory on the mounted disk.

Fixes #13.
This commit is contained in:
James Barnett
2016-11-11 15:05:12 -06:00
parent 1d9f22951c
commit 78bc6ff8b9

View File

@@ -146,7 +146,7 @@ for x in $selected_configs; do
BACKUPDIR="$selected_mnt/$mybackupdir"
mkdir -p "$BACKUPDIR"
else
mybackupdir=$(snapper -c root list -t single | awk -F"|" '/'"$selected_uuid"'/ {print $5}' | awk -F "," '{print $1}' | awk -F"=" '{print $2}')
mybackupdir=$(snapper -c root list -t single | awk -F"|" '/'"$selected_uuid"'/ {print $5}' | awk -F "," '/backupdir/ {print $1}' | awk -F"=" '{print $2}')
BACKUPDIR="$selected_mnt/$mybackupdir"
if [[ ! -d $BACKUPDIR ]]; then
printf "ERROR: %s is not a directory on %s.\n" "$BACKUPDIR" "$selected_uuid"