#!/bin/bash BACKUP_DIR="backup/$1" if [ -d "$BACKUP_DIR" ]; then >&2 echo "$BACKUP_DIR already exists. (usage: ./backup_and_reset.sh BACKUP_NAME)" exit 1 fi read -p "If you continue current config will be copied to '$BACKUP_DIR'. Continue? [y/n]" -r echo # (optional) move to a new line if [[ ! $REPLY =~ ^[Yy]$ ]] then echo "Cancelling" exit 1 fi mkdir "$BACKUP_DIR" cp www/scans "$BACKUP_DIR/" -Rv cp hit_store.db "$BACKUP_DIR/" cp scanimation/interfaces/frames "$BACKUP_DIR/" -Rv read -p "Reset or keep original files. WARNING, type yes for reset [y/n]" -r echo # (optional) move to a new line if [[ ! $REPLY =~ ^[Yy]$ ]] then echo "Exit without resetting." exit 1 fi # reset rm hit_store.db rm scanimation/interfaces/frames/*.jpg rm www/scans/*.svg echo "Done resetting files."