2023-08-18 14:08:31 +00:00
|
|
|
#!/bin/bash
|
2023-08-17 08:35:51 +00:00
|
|
|
|
2023-08-18 14:08:31 +00:00
|
|
|
if [[ -z ${KOPIA_CRON_SCHEDULE} ]];
|
|
|
|
then
|
|
|
|
echo "Running in one-shot mode"
|
2023-08-17 08:47:34 +00:00
|
|
|
|
2023-08-18 14:08:31 +00:00
|
|
|
/run-backup.sh
|
|
|
|
else
|
|
|
|
CRONTAB=/etc/cron.d/kopia-backup
|
2023-08-17 15:25:57 +00:00
|
|
|
|
2023-08-18 14:08:31 +00:00
|
|
|
printenv > /etc/environment
|
2023-08-17 08:47:34 +00:00
|
|
|
|
2023-08-18 14:08:31 +00:00
|
|
|
echo "Running cron with schedule ${KOPIA_CRON_SCHEDULE}"
|
2023-08-17 15:00:22 +00:00
|
|
|
|
2023-08-18 14:08:31 +00:00
|
|
|
echo "${KOPIA_CRON_SCHEDULE} /run-backup.sh > /var/log/kopia-backup.log 2>&1" > ${CRONTAB}
|
|
|
|
chmod 0644 ${CRONTAB}
|
|
|
|
crontab ${CRONTAB}
|
|
|
|
|
|
|
|
touch /var/log/kopia-backup.log
|
|
|
|
cron && tail -f /var/log/kopia-backup.log
|
|
|
|
fi
|