Logo Global Travelogue Project   Most Recent Grid
Journal Gallery About
Kew, England
   TECH TIPS - Crontab
  If you are running on a *nix host you may have access to crontab, allowing you to run scheduled jobs. This is excellent for doing regular admin jobs like backups and rebuilds.
   
 
May 19, 2003

You can use crontab to automatically back up your website on to another domain.

To do this your host must allow you:

  • crontab access
  • mysqldump access
  • tar access
  • gzip access
  • ncftpput access

You will probably need to ask them the path to mysqldump, tar and ncftpput.

The following crontab sends a daily copy of your MySQL database to a remote domain. It also takes a weekly backup of your complete website and transfers it to the remote domain.

MAILTO="mail@mydomain.com"
0 0 * * * /usr/local/psa/mysql/bin/mysqldump --opt -u db_user -pdb_pwd db_name | gzip | /usr/local/bin/ncftpput -u ftp_user -p ftp_pwd -c ftp.otherdomain.com target_path
0 0 * * 1 tar cvfz - local_path | /usr/local/bin/ncftpput -u ftp_user -p ftp_pwd -c ftp.otherdomain.net target_path/target_file.tar

  • mail@mydomain.com = email to send error messages to
  • db_user = username to login to your MySQL database
  • db_pwd = password for db_user
  • db_name = MySQL database name
  • ftp_user = FTP username to sign into ftp.otherdomain.com
  • ftp_pwd = password for ftp_user
  • ftp.otherdomain.com = domain to send backup files to
  • target_path = target directory to place database backup in
  • local_path = path to the top level directory of your website that you want to backup (any subdirectories will be recursively backed up)
  • target_path/target_file.tar = filename of backup of all files on your domain

Include a blank line at the end of your crontab file otherwise it will not work. The MAILTO line is also a good idea as any problems will automatically be emailed to you. Make sure you replace the placeholders in the above example!

I'm not going to explain the 0 0 * * * bit as there are plenty of articles kicking around that cover it better than I could. This is a good example

Good luck!

   
 
 
Tips Categories
         
  > Crontab    
  > Movable Type    
     
 
Fauna & Flora

Fatal error: Cannot re-assign $this in /home/snowdune/public_html/php-cgi/gallery/classes/Album.php on line 431