-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremote-plain-backup
More file actions
executable file
·39 lines (29 loc) · 899 Bytes
/
remote-plain-backup
File metadata and controls
executable file
·39 lines (29 loc) · 899 Bytes
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
#!/bin/bash
# Check for the number of arguments
if [ $# != 3 ]; then
echo "Usage: remote-backup <backup-code> <source> <target>"
exit 1
fi
wget -q --tries=10 --timeout=20 --spider http://google.com
if [ $? != 0 ]; then
echo "Error: Host is not online"
exit 2
fi
LOG_DIR=/var/log/duplicity
MAILTO="avalente@protonmail.com"
CODE=$1
SOURCE=$2
TARGET=$3
export DISPLAY=:0
# Backup directory
rclone sync -L --exclude '*.' $SOURCE $TARGET >> $LOG_DIR/$CODE.log 2>&1
if [ $? != 0 ]; then
MESSAGE="Error code: $?. $(date +'%d %b %Y %H:%M')-- Error performing the remote $SOURCE backup."
else
MESSAGE="$(date +'%d %b %Y %H:%M')-- Finished execution of remote $SOURCE backup."
fi
echo $MESSAGE >> $LOG_DIR/$CODE.log 2>&1
#kdeconnect-cli -n HONOR --send-sms "$MESSAGE" --destination $PHONE_NUMBER
# Unsetting the confidential variables so they are gone for sure.
unset PASSPHRASE
exit 0