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