From 1e680454a7e313caae949b02f6510215cfc4777f Mon Sep 17 00:00:00 2001 From: jgaunt Date: Wed, 13 Nov 2019 18:43:07 -0500 Subject: [PATCH] Add 'GauntBitwarden Backup.sh' --- GauntBitwarden Backup.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 GauntBitwarden Backup.sh diff --git a/GauntBitwarden Backup.sh b/GauntBitwarden Backup.sh new file mode 100644 index 0000000..aed43f1 --- /dev/null +++ b/GauntBitwarden Backup.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +# https://stackoverflow.com/a/185473/1388019 + +lockfile="/tmp/duplicacy.lock" +LOGFILE="/var/log/duplicacy/GauntBitwardenBackup_$(/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 /opt/bitwarden +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