those evil-natured robots, they're programmed to destroy us.

Cron jobs are a sweet way of backing up your website and MySQL databases on a scheduled basis. I use a few to ensure that I have weekly backups of my site.

“Warning: You need to have a good knowledge of Linux commands before you can use cron jobs effectively. Check your script with your hosting administrator before adding a cron job.”

Here’s my weekly file backup command:

date=`date -I` ; zip -vr -9 backup/kyle_$date.zip public_html -x /public_html/ext* -x /public_html/site.com/bigfolder*

And here’s a breakdown

1. Get the date
2. Create a zip file in a root directory called backup called kyle_date.zip from everything in the web directory
3. Exclude this big directory ┬áthat I don’t need backed up

Here’s the same for MySQL:

date=`date -I` ; mysqldump -hlocalhost -ukyle_user -pPASSWORD kyle_database | gzip > backup/kyle_database_$date.sql.gz

1. Get the date
2. Use mysqldump to generate a backup of database kyle_database using username of  kyle_user and password
3. Store it in the same backup directory as the file backup as kyle_database_date.sql.gz