mirror of
https://github.com/lobaro/restic-backup-docker.git
synced 2026-04-04 04:08:51 +00:00
added general repository checking
This commit is contained in:
16
entry.sh
16
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
|
||||
Reference in New Issue
Block a user