From 63a7e01227ec1f01ff526e68fbc2fa6ff530b8ab Mon Sep 17 00:00:00 2001 From: John Gaunt Date: Tue, 17 Nov 2020 22:22:09 -0500 Subject: [PATCH] changed to debian and added cron --- duplicacy/config.json | 4 +++- duplicacy/dockerfile | 7 +++++-- duplicacy/run.sh | 15 +++++++++++---- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/duplicacy/config.json b/duplicacy/config.json index 052f1c0..60afbc9 100644 --- a/duplicacy/config.json +++ b/duplicacy/config.json @@ -1,6 +1,6 @@ { "name": "duplicacy", - "version": "20201117.13", + "version": "20201117.14", "slug": "duplicacy", "description": "Duplicacy backup", "arch": ["armhf", "armv7"], @@ -15,6 +15,7 @@ "ssh_password": "password", "server": "server.example.com", "path": "/opt/some/folder/on/on/server", + "crontab_run": "*/5 * * * *", "filters": [ "i:addons/.*", "i:backup/.*", @@ -30,6 +31,7 @@ "ssh_password": "str", "server": "str", "path": "str", + "crontab_run": "str", "filters": ["match(^i:|e:)"] } } \ No newline at end of file diff --git a/duplicacy/dockerfile b/duplicacy/dockerfile index b79a4a0..c327971 100644 --- a/duplicacy/dockerfile +++ b/duplicacy/dockerfile @@ -1,8 +1,11 @@ -ARG BUILD_FROM -FROM $BUILD_FROM +ARG BUILD_FROM=debian:buster-20201012-slim +FROM ${BUILD_FROM} ENV LANG C.UTF-8 +# Install cron +RUN apt-get -y install -qq --force-yes cron + # Copy data for add-on COPY run.sh / COPY duplicacy_linux_arm_2.7.2 /duplicacy diff --git a/duplicacy/run.sh b/duplicacy/run.sh index d626a0f..b5348d2 100644 --- a/duplicacy/run.sh +++ b/duplicacy/run.sh @@ -12,6 +12,7 @@ SSH_PASSWORD=$(jq --raw-output ".ssh_password" $CONFIG_PATH) BACKUP_SERVER=$(jq --raw-output ".server" $CONFIG_PATH) BACKUP_SERVER_PATH=$(jq --raw-output ".path" $CONFIG_PATH) FILTERS=$(jq --raw-output ".filters" $CONFIG_PATH) +CRONTAB_RUN=$(jq --raw-output ".crontab_run" $CONFIG_PATH) # edit the /.duplicacy/preferences file sed --in-place 's//'${BACKUP_ID}'/' /.duplicacy/preferences @@ -24,8 +25,14 @@ sed --in-place 's~~'${BACKUP_SERVER_PATH}'~' /.duplicacy/pre # create the filters file echo ${FILTERS} | jq -r '.[]' >> /.duplicacy/filters -# backup all the data -#/duplicacy -verbose -log backup -stats -# testing snaphots -ha sn list \ No newline at end of file +# backup all the data using cron +echo "${CRONTAB_RUN} /duplicacy -verbose -log backup -stats" >> /etc/cron.d/duplicacy +# Give execution rights on the cron job +chmod 0644 /etc/cron.d/duplicacy +# Apply cron job +crontab /etc/cron.d/duplicacy +# Create the log file to be able to run tail +touch /var/log/cron.log +# Run the command on container startup +cron && tail -f /var/log/cron.log \ No newline at end of file