add option to exit

This commit is contained in:
James Barnett
2016-09-24 16:04:39 -05:00
parent b26ed560e2
commit 2ee381ae95

13
backup
View File

@@ -46,14 +46,17 @@ for x in $UUIDS; do
i=$(($i+1))
done
total_mounted=$i
echo "The following mounted BTRFS devices were found."
disk=0
while [[ $disk < 1 || $disk > $i ]]; do
echo "Selected a mounted BTRFS device to backup to:"
while [[ $disk < 0 || $disk > $i ]]; do
for x in ${!TARGETS_ARRAY[@]}; do
echo -e "$(($x+1))) ${UUIDS_ARRAY[$x]}\t(${TARGETS_ARRAY[$x]})"
done
echo "0) Exit"
read -p "Select one: " disk
done
if [[ $disk == 0 ]]; then
exit 0
fi
selected_uuid="${UUIDS_ARRAY[$(($disk-1))]}"
echo "You selected the disk with UUID $selected_uuid."
@@ -64,8 +67,6 @@ else
exit 1
fi
echo "Performing backup..."
for x in $SNAPPER_CONFIGS; do
# shellcheck source=/dev/null
@@ -87,6 +88,7 @@ for x in $SNAPPER_CONFIGS; do
BACKUPDIR="$(findmnt -n -v -t btrfs -o UUID,TARGET --list | awk '/'$selected_uuid'/ {print $2}')/$mybackupdir"
backup_location=$BACKUPDIR/$x/$new_number/
echo "This will be the initial backup for snapper configuration '$x' to this disk. This could take awhile."
echo "Backup location: $backup_location"
read -n 1 -p "Continue (y/n)? " cont_backup
echo
@@ -94,7 +96,6 @@ for x in $SNAPPER_CONFIGS; do
continue
fi
mkdir -p "$backup_location"
echo "Performing initial backup for snapper configuration '$x'. This could take awhile..."
btrfs send "$new_snapshot" | btrfs receive "$backup_location"
else