added general repository checking

This commit is contained in:
Stefan Bratic
2019-06-19 10:18:06 +00:00
parent 393cc232c1
commit 5e99ccbc9f

View File

@@ -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