#!/bin/bash sudo echo ">>> Initialising" if [[ `id -u` == 0 ]]; then echo "WARNING: Running as root? This might not be what you want..." fi SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )" echo ">>> Checking validity of image" if $SCRIPTPATH/disk-backup-check "$1"; then if stat "$2"; then sudo umount "$2" &> /dev/null set -e set -o pipefail echo ">>> Will restore $1 to $2" read -p "Is this okay (y/N)? " -n 1 -r echo if [[ $REPLY =~ ^[Yy]$ ]]; then if cat "$1" | openssl aes-192-cbc -salt -d | gunzip -c | sudo dd conv=sync,noerror "of=$2" status=progress; then echo ">>> Done" else echo "ERROR - Failure, corruption likely" fi else echo "Doing nothing" fi else echo "ERROR - No such device" fi fi