From 597c9b72ab2f5442e5d668875d2560abae37ab3b Mon Sep 17 00:00:00 2001 From: jgaunt Date: Wed, 30 Oct 2019 16:57:25 -0400 Subject: [PATCH] Add 'GauntNAS Backup.sh' --- GauntNAS Backup.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 GauntNAS Backup.sh diff --git a/GauntNAS Backup.sh b/GauntNAS Backup.sh new file mode 100644 index 0000000..f631474 --- /dev/null +++ b/GauntNAS Backup.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +# https://stackoverflow.com/a/185473/1388019 + +lockfile="/tmp/duplicacy.lock" +LOGFILE="/mnt/data-pool/configBackups/Duplicacy/logs/GauntNASConfigBackup_$(/bin/date +%Y%m%d-%H%M%S).log" + + +if [ -e ${lockfile} ] && kill -0 `cat ${lockfile}`; then + echo "duplicacy backup already running" >> ${LOGFILE} + exit +fi + +# make sure the lockfile is removed when we exit and then claim it +trap "rm -f ${lockfile}; exit" INT TERM EXIT +echo $$ > ${lockfile} + +# run the backup +cd /data +/mnt/data-pool/configBackups/Duplicacy/duplicacy -verbose -log backup -stats >> ${LOGFILE} 2>&1 + +# compress the logs +/usr/bin/gzip $(/usr/bin/dirname ${LOGFILE})/*.log + +# clean up lockfile +rm -f ${lockfile} \ No newline at end of file