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