mirror of
https://github.com/ViViDboarder/docker-restic-cron.git
synced 2024-11-05 04:46:35 +00:00
41 lines
1.0 KiB
Bash
41 lines
1.0 KiB
Bash
|
#! /bin/bash
|
||
|
|
||
|
export OPT_ARGUMENTS="$@"
|
||
|
|
||
|
if [ "$1" == "bash" ]; then
|
||
|
exec "$@"
|
||
|
exit 0
|
||
|
fi
|
||
|
|
||
|
if [ "$SKIP_ON_START" != "true" ]; then
|
||
|
/backup.sh
|
||
|
fi
|
||
|
|
||
|
if [ -n "$CRON_SCHEDULE" ]; then
|
||
|
# Export the environment to a file so it can be loaded from cron
|
||
|
env | sed 's/^\(.*\)=\(.*\)$/export \1="\2"/g' > /env.sh
|
||
|
# Remove some vars we don't want to keep
|
||
|
sed -i '/\(HOSTNAME\|affinity\|SHLVL\|PWD\)/d' /env.sh
|
||
|
|
||
|
# Use bash for cron
|
||
|
echo "SHELL=/bin/bash" > /crontab.conf
|
||
|
|
||
|
# Schedule the backups
|
||
|
echo "$CRON_SCHEDULE source /env.sh && /backup.sh 2>> /cron.log" >> /crontab.conf
|
||
|
echo "Backups scheduled as $CRON_SCHEDULE"
|
||
|
|
||
|
if [ -n "$VERIFY_CRON_SCHEDULE" ]; then
|
||
|
echo "$VERIFY_CRON_SCHEDULE source /env.sh && duplicity verify $BACKUP_DEST $PATH_TO_BACKUP" >> /crontab.conf
|
||
|
echo "Verify scheduled as $VERIFY_CRON_SCHEDULE"
|
||
|
fi
|
||
|
|
||
|
# Add to crontab
|
||
|
crontab /crontab.conf
|
||
|
|
||
|
echo "Starting duplicity cron..."
|
||
|
cron
|
||
|
|
||
|
touch /cron.log /root/duplicity.log
|
||
|
tail -f /cron.log /root/duplicity.log
|
||
|
fi
|