-
Notifications
You must be signed in to change notification settings - Fork 6
/
borg-mount.sh
executable file
·57 lines (45 loc) · 1.5 KB
/
borg-mount.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
#!/usr/bin/env bash
###############################
# script mounts borg repo from .env
# to defined mount directory
# DO NOT FORGET TO UNMOUNT!!
# borg unmount MOUNT_DIR
##############################
# load values from .env
set -o allexport
eval $(cat '.env' | sed -e '/^#/d;/^\s*$/d' -e 's/\(\w*\)[ \t]*=[ \t]*\(.*\)/\1=\2/' -e "s/=['\"]\(.*\)['\"]/=\1/g" -e "s/'/'\\\''/g" -e "s/=\(.*\)/='\1'/g")
set +o allexport
# Setting this, so the repo does not need to be given on the commandline:
export BORG_REPO=${ENV_BORG_REPO}
export BORG_PASSPHRASE=${ENV_BORG_PASSPHRASE}
export BORG_RESTORE_MOUNT=${ENV_BORG_RESTORE_MOUNT}
echo
echo
echo "----------------------------------------"
echo "--- MOUNTING BACKUP REPO FOR RESTORE ---"
echo "----------------------------------------"
echo
# first try to unmount if existting
if borg umount ${BORG_RESTORE_MOUNT}; then
echo "Restore folder unmounted"
else
echo "No restore folder mounted!"
fi
##
## mount repo restore to defined directory
##
mkdir -p ${BORG_RESTORE_MOUNT}
chmod a-w ${BORG_RESTORE_MOUNT}
echo "Mounting Repository to ${BORG_RESTORE_MOUNT}"
borg mount ${BORG_REPO} ${BORG_RESTORE_MOUNT}
echo "Switch to ${BORG_RESTORE_MOUNT} to browse backup archives!"
echo
echo "--- Showing list of available backups ---"
echo
ls -al ${BORG_RESTORE_MOUNT}
echo
echo
echo "-------------------------------------------"
echo "MAKE SURE TO UNMOUNT REPO WHEN FINISHED WHITH"
echo "$ borg umount ${BORG_RESTORE_MOUNT}"
echo "-------------------------------------------"