Backing Up Data With Cron Jobs

Description

There are various ways and programs of backing up your systems, but I prefer to control all aspects of my backups and therefore will use cron jobs to do my backups. There are several different types of crons, but they all function the same way.

First you need to open your crontab for editing by simply using
[bash]
crontab -e
[/bash]

Example:

The example I am using to show backups will be for my website here, but this can work with anything. The ‘-u’ is for the username and ‘-p’ is for the password
[bash]
0 2 * * * mysqldump -u zaphinath -p password -h zaphinath > /system/backup/zaphinath.daily.sql
0 2 * * * tar cjf /system/backup/zaphinath.daily.tar.bz2 /var/www/zaphinath/
10 2 * * * bzip2 /system/backup | ssh minastirith.zaphinath.com
[/bash]
This will backup my sql database and my files for my website at 2:00 A.M. and then backup my backup folder at 2:10 and send it to one of my servers. The one thing this requires is keygen to be set up. For a complete list of crontab options go to my cron cheat sheet.

Leave a Reply

Your email address will not be published. Required fields are marked *