PHP on the command line

Executing the backup automatically
It is recommended to do backups daily. Everybody knows that.
On *NIX systems this is usually done by invoking backup functions with cron.

Cron is a daemon that runs in the background and checks on a regular basis if there is anything to do. It does that by looking into each user's crontab.
For our backup script we only have to do three things:

  • Download this script (SimpleBackup.php), unpack it and move it where you want. Edit it to your needs.
  • Or, even better, if you have followed the howto take your new script and call it SimpleDownload.php
  • Make sure the script is executable (chmod -a+rx /path/to/SimpleBackup.php)
  • Add an entry in your crontab
The latter is done by invoking your crontab with the command crontab -e and then add this line #0: <?
#1:
@daily /path/to/SimpleBackup.php >> /dev/null 2>&1   
This executes SimpleBackup.php every day (usually very early in the morning).
The ">> /dev/null 2>&1" part simply means that all output is deleted.

That's all there is. Really. Hope you found it useful.
Previous:Sample application: SimpleBackup.php Start

My Sites