1 6.0 Scheduling via cron
Asif Bacchus edited this page 2020-05-24 03:03:04 -06:00
This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

scheduling - using cron

After running this script at least once manually to test your settings, you should schedule it to run automatically so things stay backed up. This is easiest with a simple cron job.

  1. Open root's crontab

    sudo crontab -e
    
  2. Add your script command line and set the time for execution. I'm assuming your script is located at '/scripts/backup, all files are at their default locations, you are using the 503-page functionality with default files, and you want to run your backup at 1:07am daily.

    7 1 * * * /scripts/backup/backup.sh -l /var/log/mailcowbackup.log -5 > /dev/null 2>&1
    

    The part after the script command (the '>' and stuff after it) means redirect all output to null. This is good so that errors don't junk up your system logs and it doesn't log to your console since no one is around to see it. This is standard practice for running things via cron. That's why periodically reviewing your log file is important!

  3. Save the file (yes, accept that weird random-looking filename) and exit.

  4. Confirm your changes by listing the root user's crontab:

    sudo crontab -l