-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.sh
64 lines (60 loc) · 1.29 KB
/
main.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# Import vars. and funcs.
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
if [ -n "$1" ]; then
source "$1"
else
source "$HERE"/vars.sh
fi
source "$HERE"/lib.sh
echo 'Restic Backup'
# Ask for Restic password if env. var. not provided
resticAskPass
# Present choices on loop
while [ true ]; do
echo ''
echo "Pick an action: "
echo '1) Backup'
echo '2) Forget'
echo '3) Prune'
echo '4) List Backup Snapshots'
echo '5) Check Backup Integrity'
echo '6) Mount'
echo '7) Freeform'
echo '*) Exit'
read choice
case $choice in
1) # Backup
INITCOMMAND="init"
DATE="$(date +"%Y-%m-%d-%H-%M")"
BACKUPCOMMAND="backup $LOCALPATH -v $BACKUPOPTIONS"
resticLocalCommand "$INITCOMMAND" 2>/dev/null
resticLocalCommand "$BACKUPCOMMAND"
;;
2) # Forget
resticLocalCommand "forget ${RETENTIONPOLICY}"
;;
3) #Prune
PRUNECOMMAND="prune"
DATE="$(date +"%Y-%m-%d-%H-%M")"
resticLocalCommand "$PRUNECOMMAND"
;;
4) # List
resticLocalCommand "snapshots"
;;
5) # Check
resticLocalCommand "check"
;;
6) # Mount
if [ ! -d ~/resticBackup ]; then mkdir ~/resticBackup; fi
resticLocalCommand "mount /home/$(whoami)/resticBackup" && ~/resticBackup
;;
7) # Freeform
echo 'Enter the Restic command: '
read RC
resticLocalCommand "${RC}"
;;
*)
exit
;;
esac
done