diff --git a/CHANGELOG.md b/CHANGELOG.md index aea098d..97f167f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ Still In Development Mail: * Update Roundcube to version 1.1.3. +* Nightly backups and system status checks are now moved to 3am in the system's timezone. v0.14 (November 4, 2015) ------------------------ diff --git a/management/daily_tasks.sh b/management/daily_tasks.sh new file mode 100755 index 0000000..6237e6c --- /dev/null +++ b/management/daily_tasks.sh @@ -0,0 +1,8 @@ +#!/bin/bash +# This script is run daily (at 3am each night). + +# Take a backup. +management/backup.py + +# Run status checks and email the administrator if anything changed. +management/status_checks.py --show-changes --smtp diff --git a/setup/management.sh b/setup/management.sh index 4effb67..096403b 100755 --- a/setup/management.sh +++ b/setup/management.sh @@ -30,33 +30,18 @@ rm -f /etc/init.d/mailinabox ln -s $(pwd)/conf/management-initscript /etc/init.d/mailinabox hide_output update-rc.d mailinabox defaults -# Set time zone to something convenient for the user -# Backup will be set for 3am localtime so choice is important depending -# on user locations. +# Remove old files we no longer use. +rm -f /etc/cron.daily/mailinabox-backup +rm -f /etc/cron.daily/mailinabox-statuschecks -dpkg-reconfigure tzdata +# Perform nightly tasks at 3am in system time: take a backup, run +# status checks and email the administrator any changes. -# Perform a daily backup. -if [ -f /etc/cron.daily/mailinabox-backup ]; then - rm /etc/cron.daily/mailinabox-backup -fi -cat > /etc/cron.d/mailinabox-backup << EOF; -# /etc/cron.d/mailinabox-backup: crontab fragment to run maininabox-backup -# This executes $(pwd)/management/backup.py at 3am. - -0 3 * * * root $(pwd)/management/backup.py -EOF - -# Perform daily status checks. Compare each day to the previous -# for changes and mail the changes to the administrator. -cat > /etc/cron.daily/mailinabox-statuschecks << EOF; -#!/bin/bash +cat > /etc/cron.d/mailinabox-nightly << EOF; # Mail-in-a-Box --- Do not edit / will be overwritten on update. -# Run status checks. -$(pwd)/management/status_checks.py --show-changes --smtp +# Run nightly tasks: backup, status checks. +0 3 * * * root (cd `pwd` && management/daily_tasks.sh) EOF -chmod +x /etc/cron.daily/mailinabox-statuschecks - # Start it. restart_service mailinabox