forked from hortio/docker-restic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackup.sh
executable file
·35 lines (30 loc) · 904 Bytes
/
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
#!/bin/sh
start=`date +%s`
echo "Starting Backup at $(date +"%Y-%m-%d %H:%M:%S")"
echo "BACKUP_CRON: ${BACKUP_CRON}"
echo "RESTIC_FORGET_ARGS: ${RESTIC_FORGET_ARGS}"
echo "RESTIC_JOB_ARGS: ${RESTIC_JOB_ARGS}"
restic backup /data ${RESTIC_JOB_ARGS} 2>&1
rc=$?
echo "Finished backup at $(date)"
if [[ $rc == 0 ]]; then
echo "Backup Successfull"
else
echo "Backup Failed with Status ${rc}"
restic unlock
kill 1
fi
if [ -n "${RESTIC_FORGET_ARGS}" ]; then
echo "Forget about old snapshots based on RESTIC_FORGET_ARGS = ${RESTIC_FORGET_ARGS}"
restic forget ${RESTIC_FORGET_ARGS} 2>&1
rc=$?
echo "Finished forget at $(date)"
if [[ $rc == 0 ]]; then
echo "Forget Successfull"
else
echo "Forget Failed with Status ${rc}"
restic unlock
fi
fi
end=`date +%s`
echo "Finished Backup at $(date +"%Y-%m-%d %H:%M:%S") after $((end-start)) seconds"