From 5e99ccbc9f80c384204d5bbe782e25a35077707c Mon Sep 17 00:00:00 2001 From: Stefan Bratic Date: Wed, 19 Jun 2019 10:18:06 +0000 Subject: [PATCH] added general repository checking --- entry.sh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/entry.sh b/entry.sh index a01f82d..42ae1d8 100755 --- a/entry.sh +++ b/entry.sh @@ -1,5 +1,4 @@ #!bin/sh -set -e echo "Starting container ..." @@ -14,11 +13,22 @@ if [ -n "${NFS_TARGET}" ]; then mount -o nolock -v ${NFS_TARGET} /mnt/restic fi -if [ ! -f "$RESTIC_REPOSITORY/config" ]; then +restic snapshots &>/dev/null +status=$? +echo "Check Repo status $status" + +if [ $status != 0 ]; then echo "Restic repository '${RESTIC_REPOSITORY}' does not exists. Running restic init." restic init | true + + if [ $? == 0 ]; then + echo "Failed to init the repository: '${RESTIC_REPOSITORY}'" + exit 1 + fi fi + + echo "Setup backup cron job with cron expression BACKUP_CRON: ${BACKUP_CRON}" echo "${BACKUP_CRON} /bin/backup >> /var/log/cron.log 2>&1" > /var/spool/cron/crontabs/root @@ -30,4 +40,4 @@ crond echo "Container started." -tail -fn0 /var/log/cron.log +tail -fn0 /var/log/cron.log \ No newline at end of file