restic-docker/backup.sh

36 lines
940 B
Bash
Raw Normal View History

2019-06-06 06:37:26 +00:00
#!/bin/sh
start=`date +%s`
echo "Starting Backup at $(date +"%Y-%m-%d %H:%M:%S")"
echo "RESTIC_REPOSITORY: ${RESTIC_REPOSITORY}"
echo "BACKUP_CRON: ${BACKUP_CRON}"
echo "RESTIC_JOB_ARGS: ${RESTIC_JOB_ARGS}"
echo "RESTIC_FORGET_ARGS: ${RESTIC_FORGET_ARGS}"
restic backup /data ${RESTIC_JOB_ARGS}
rc=$?
echo "Finished backup at $(date)"
if [[ $rc == 0 ]]; then
echo "Backup Successful"
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}
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"