Adding restore functionality, fixes #6

This commit is contained in:
Andrew Davidson 2021-07-16 06:46:59 -07:00
parent 4db272d957
commit c8f66d3976
Signed by: amd
GPG key ID: 17AF8F2A49CF25C6

View file

@ -23,9 +23,12 @@ print_help () {
backup - initiate a backup of the home folder to the destination backup - initiate a backup of the home folder to the destination
check - check repository for consistency check - check repository for consistency
find - find a file by a string in the repository (requires input) find - find a file by a string in the repository (requires input)
ex: backup.sh find s3 critical_file.doc
help - print this help help - print this help
init - intiialize a new backup repository init - intiialize a new backup repository
prune - prune old backups on the destination prune - prune old backups on the destination
restore - restores file from repository (requires input)
ex: backup.sh restore s3 latest --target=/tmp/restore --include=/home/user/Documents
snapshots - list backups on the destination snapshots - list backups on the destination
stats - print statistics about the backup repository stats - print statistics about the backup repository
unlock - unlock a locked repository - use for stale locks unlock - unlock a locked repository - use for stale locks
@ -128,6 +131,10 @@ else
--verbose \ --verbose \
find $INPUT find $INPUT
;; ;;
"help")
print_logo
print_help
;;
"init") "init")
echo "Initializing backup repository at $DESTINATION" | print_and_log echo "Initializing backup repository at $DESTINATION" | print_and_log
/usr/bin/restic \ /usr/bin/restic \
@ -136,13 +143,13 @@ else
--verbose \ --verbose \
init | print_and_log init | print_and_log
;; ;;
"unlock") "restore")
echo "Unlocking backup repository at $DESTINATION" | print_and_log echo "Restoring from $DESTINATION, $INPUT" | print_and_log
/usr/bin/restic \ /usr/bin/restic \
-r "$BACKUP_REPOSITORY" \ -r "$BACKUP_REPOSITORY" \
-p "$BACKUP_PASSWORD" \ -p "$BACKUP_PASSWORD" \
--verbose \ --verbose \
unlock | print_and_log restore $INPUT | print_and_log
;; ;;
"snapshots") "snapshots")
echo "Listing snapshots on $DESTINATION" echo "Listing snapshots on $DESTINATION"
@ -184,9 +191,13 @@ else
echo "Not plugged in, canceling prune." echo "Not plugged in, canceling prune."
fi fi
;; ;;
"help") "unlock")
print_logo echo "Unlocking backup repository at $DESTINATION" | print_and_log
print_help /usr/bin/restic \
-r "$BACKUP_REPOSITORY" \
-p "$BACKUP_PASSWORD" \
--verbose \
unlock | print_and_log
;; ;;
*) *)
echo "Action: $ACTION not recognized." echo "Action: $ACTION not recognized."