forked from calr0x/OT-Smoothbrain-Backup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrestic-coldbrain-backup.sh
executable file
·67 lines (50 loc) · 1.76 KB
/
restic-coldbrain-backup.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
65
66
67
#!/bin/bash
# This only works on dockerless nodes !
# This will stop the node and then the arangodb server, backup any changed data directly from the arango folder, and then restart arango, and then the node.
# The initial backup will take some time!
source "/root/OT-Settings/config.sh"
STATUS=$?
N1=$'\n'
echo "Stopping otnode"
systemctl stop otnode
if [ $? -ne 0 ]; then
/root/OT-Settings/data/send.sh "Stopping otnode service failed during backup."
fi
echo "Stopping arangodb3"
systemctl stop arangodb3
if [ $? -ne 0 ]; then
/root/OT-Settings/data/send.sh "Stopping arangodb3 service failed during backup."
fi
echo "Uploading data to Amazon S3"
OUTPUT=$(/root/OT-Smoothbrain-Backup/restic backup --tag coldbackup /ot-node/current/.origintrail_noderc /root/.origintrail_noderc /var/lib/arangodb3 /var/lib/arangodb3-apps 2>&1)
if [ $? -eq 0 ]; then
if [ $SMOOTHBRAIN_NOTIFY_ON_SUCCESS == "" ]; then
$SMOOTHBRAIN_NOTIFY_ON_SUCCESS="true"
fi
if [ $SMOOTHBRAIN_NOTIFY_ON_SUCCESS == "true" ]; then
/root/OT-Settings/data/send.sh "Backup SUCCESSFUL:${N1}$OUTPUT"
fi
else
/root/OT-Settings/data/send.sh "Uploading backup to S3 FAILED:${N1}$OUTPUT"
systemctl start arangodb3
if [ $? -ne 0 ]; then
/root/OT-Settings/data/send.sh "Starting arangodb3 service failed during backup."
fi
systemctl start otnode
if [ $? -ne 0 ]; then
/root/OT-Settings/data/send.sh "Starting otnode service failed during backup."
fi
exit 1
fi
echo "Starting otnode and arangodb3"
systemctl start arangodb3
if [ $? -ne 0 ]; then
/root/OT-Settings/data/send.sh "Starting arangodb3 service failed during backup."
exit 1
fi
systemctl start otnode
if [ $? -ne 0 ]; then
/root/OT-Settings/data/send.sh "Starting otnode service failed during backup."
exit 1
fi
exit 0