-
Notifications
You must be signed in to change notification settings - Fork 1
/
run.sh
41 lines (30 loc) · 903 Bytes
/
run.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
#!/bin/bash
#Check veriables or set defaults
if [ -z ${WEBDRIVE_USER} ]; then
echo "Webdrive user is not set"
fi
if [ -z ${WEBDRIVE_PASSWORD} ]; then
echo "Webdrive password is not set"
fi
if [ -z ${WEBDRIVE_URL} ]; then
echo "Webdrive url is not set"
fi
USER=${WEBDRIVE_USER}
PASSWORD=${WEBDRIVE_PASSWORD}
URL=${WEBDRIVE_URL}
FOLDER_USER=${SYNC_USERID:-0}
echo "$URL $USER $PASSWORD" >> /etc/davfs2/secrets
# Create user
if [ $FOLDER_USER -gt 0 ]; then
useradd webdrive -u $FOLDER_USER -N -G users
fi
# Mount the webdav drive
mount -t davfs $URL /mnt/webdrive -o uid=$FOLDER_USER,gid=users,dir_mode=755,file_mode=755
#update borgmatic config file
sed -i "s|REPO_NAME|$REPO_NAME|g" /etc/borgmatic/config.yaml
#initialize borg repository
~/.local/bin/borgmatic init --encryption repokey
#Make backup
~/.local/bin/borgmatic --verbosity 1
#Unmount the webdav drive
umount /mnt/webdrive