-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrsync_volumes.sh
41 lines (37 loc) · 1.2 KB
/
rsync_volumes.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/sh
logdir="/var/log/volume-backup"
logname="$(date +"%Y-%m-%d-%H-%M")-volume-backup.txt"
begin=$(date +%s) #Starttime rsync
backup_function(){
if [ -f /app/.dryrun ]
then
rsync -avri -n -h --delete /volumes/ /backup/ | tee "$logdir/$logname"
else
rsync -avri -h --delete /volumes/ /backup/ | tee "$logdir/$logname"
fi
}
echo -e "${green}"
echo -e "--------------------------------------------------------"
echo -e "$(date)"
echo -e "Start backup of docker volumes"
echo -e "--------------------------------------------------------"
echo -e "${reset}"
if ( backup_function )
then
## Calculating rsync time
end=$(date +%s) #Endtime rsync
tottime=$(expr $end - $begin)
echo -e "${green}"
echo -e "--------------------------------------------------------"
echo -e "$(date)"
echo -e "Successfully finished backup of docker volumes."
echo -e "Duration: $tottime seconds"
/app/delete_old_logs.sh
echo -e "${green}--------------------------------------------------------"
echo -e "${reset}"
## HEAD-Request to URL for monitoring if script ran successfully
/app/uptime_push.sh
/app/delete_old_logs.sh
else
echo -e "Error: Backup was not fully successful. Check the $logdir/$logname for more info."
fi