making generic to run on multiple systems

This commit is contained in:
Andrew Davidson 2023-08-18 09:03:13 -07:00
parent e972c90fe5
commit 718431b361
Signed by: amd
SSH key fingerprint: SHA256:6jDSUhitcXG0Nrh/g8Gy8ZJdsZ5LzPJlaGmGKUGfP5k
3 changed files with 12 additions and 11 deletions

View file

@ -61,7 +61,7 @@ print_help () {
}
print_and_log () {
/usr/bin/ts "%Y-%m-%dT%H:%M:%S" | /usr/bin/tee -a $BACKUP_LOG
/usr/bin/env ts "%Y-%m-%dT%H:%M:%S" | /usr/bin/tee -a $BACKUP_LOG
}
set -o errexit
@ -70,6 +70,7 @@ set -o pipefail
ACTION=$1
DESTINATION=$2
INPUT="${@:3}"
RESTIC=$(which restic)
if [[ -z $DESTINATION && $ACTION == "help" ]]; then
print_logo
@ -105,7 +106,7 @@ else
"backup")
if [[ $AC_POWER == 1 ]]; then
echo "backing up to $DESTINATION." | print_and_log
/usr/bin/restic \
RESTIC \
-r "$BACKUP_REPOSITORY" \
-p "$BACKUP_PASSWORD" \
--cleanup-cache \
@ -120,7 +121,7 @@ else
;;
"check")
echo "Checking backup repository at $DESTINATION" | print_and_log
/usr/bin/restic \
RESTIC \
-r "$BACKUP_REPOSITORY" \
-p "$BACKUP_PASSWORD" \
--verbose \
@ -128,7 +129,7 @@ else
;;
"find")
echo "Searching for $INPUT at $DESTINATION"
/usr/bin/restic \
RESTIC \
-r "$BACKUP_REPOSITORY" \
-p "$BACKUP_PASSWORD" \
--verbose \
@ -140,7 +141,7 @@ else
;;
"init")
echo "Initializing backup repository at $DESTINATION" | print_and_log
/usr/bin/restic \
RESTIC \
-r "$BACKUP_REPOSITORY" \
-p "$BACKUP_PASSWORD" \
--verbose \
@ -148,7 +149,7 @@ else
;;
"mount")
echo "Mounting backup repository $DESTINATION at $INPUT" | print_and_log
/usr/bin/restic \
RESTIC \
-r "$BACKUP_REPOSITORY" \
-p "$BACKUP_PASSWORD" \
--verbose \
@ -156,7 +157,7 @@ else
;;
"restore")
echo "Restoring from $DESTINATION, $INPUT" | print_and_log
/usr/bin/restic \
RESTIC \
-r "$BACKUP_REPOSITORY" \
-p "$BACKUP_PASSWORD" \
--verbose \
@ -164,7 +165,7 @@ else
;;
"snapshots")
echo "Listing snapshots on $DESTINATION"
/usr/bin/restic \
RESTIC \
-r "$BACKUP_REPOSITORY" \
-p "$BACKUP_PASSWORD" \
--verbose \
@ -172,7 +173,7 @@ else
;;
"stats")
echo "Printing statistics for $DESTINATION"
/usr/bin/restic \
RESTIC \
-r "$BACKUP_REPOSITORY" \
-p "$BACKUP_PASSWORD" \
--verbose \
@ -204,7 +205,7 @@ else
;;
"unlock")
echo "Unlocking backup repository at $DESTINATION" | print_and_log
/usr/bin/restic \
RESTIC \
-r "$BACKUP_REPOSITORY" \
-p "$BACKUP_PASSWORD" \
--verbose \
@ -212,7 +213,7 @@ else
;;
"clean")
echo "Cleaning repository at $DESTINATION" | print_and_log
/usr/bin/restic \
RESTIC \
-r "$BACKUP_REPOSITORY" \
-p "$BACKUP_PASSWORD" \
--verbose \