This repository has been archived on 2021-02-24. You can view files and clone it, but cannot push or open issues or pull requests.
Files
duplicacy-scripts-OLD/duplicacy.sh
2020-07-30 17:08:16 -04:00

64 lines
2.3 KiB
Bash

#!/bin/sh
lockfile="/tmp/duplicacy.lock"
LOGFILE="/var/log/duplicacy/duplicacy_$(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}
# Duplicacy version update
LATEST_DUPLICACY_VERSION="2.6.1"
INSTALLED_DUPLICACY_VERSION=$(duplicacy -h | awk '/VERSION:/{getline; print $1}')
if [ ${LATEST_DUPLICACY_VERSION} != ${INSTALLED_DUPLICACY_VERSION} ]; then
# Determine the Kernel and Architecture
KERNEL=$(uname)
ARCH=$(uname -m)
if [ ${KERNEL} == 'Linux' ]; then
if [ ${ARCH} == 'x86_64' ]; then
cp -v $(dirname "$0")/binaries/duplicacy_linux_x64_2.6.1 /usr/bin/duplicacy >> ${LOGFILE}
chmod +x /usr/bin/duplicacy >> ${LOGFILE}
elif [ ${ARCH} == 'aarch64' ]; then
cp -v $(dirname "$0")/binaries/duplicacy_linux_arm64_2.6.1 /usr/bin/duplicacy >> ${LOGFILE}
chmod +x /usr/bin/duplicacy >> ${LOGFILE}
else
echo "Kernel Type: ${KERNEL}"
echo "Arch: ${ARCH}"
echo "Arch not supported."
exit
fi
elif [ ${KERNEL} == 'FreeBSD' ]; then
if [ ${ARCH} == 'amd64' ]; then
cp -v $(dirname "$0")/binaries/duplicacy_freebsd_x64_2.6.1 /usr/bin/duplicacy >> ${LOGFILE}
chmod +x /usr/bin/duplicacy >> ${LOGFILE}
else
echo "Kernel Type: ${KERNEL}"
echo "Arch: ${ARCH}"
echo "Arch not supported."
exit
fi
else
echo "Kernel Type: ${KERNEL}"
echo "Arch: ${ARCH}"
echo "Kernel not supported."
exit
fi
fi
# run the backup
cd /
duplicacy -verbose -log backup -stats >> ${LOGFILE} 2>&1
# prune the backup
duplicacy -verbose -log prune -keep 0:360 -keep 30:180 -keep 7:30 -keep 1:7 >> ${LOGFILE} 2>&1
# compress the logs
gzip $(dirname ${LOGFILE})/*.log
# clean up lockfile
rm -f ${lockfile}