Hara maheshvara shulapani pinakadhrik pashupati shiva mahadeva
Surely some of your data is very important to you, whether it's email, school or work papers, professional records and works in progress, financial and tax records, photos, music or films, whatever. For me, it's about 10 years of professional output plus email and some digital photos and music. I'd hate to lose all of that, so I make sure that I back up all my data regularly.
If you're like most of us, you might have a CD or DVD burner in your system, and that's fine for periodic backups. But how often do you remember to do that, burn a backup CD or DVD? Once a month? Once every six months? Maybe once a year, if you're lucky? It's better to have an automatic backup process.
If you run Windows, you can buy backup programs to copy all your data to a second hard disk, an external hard disk or even tape. All you need is the money to buy the software plus the storage media. So if you run Windows, there are commercial data backup resources available to you, and good luck to you.
Commercial backup software is available for Linux as well, but unless you're running a data center for a business those are likely more, and more expensive, than you really need. If you run Linux, you're fortunate because Linux includes system features and utilities that make it easy to automate backups. Here I'll show how to set up a daily backup to a second hard disk.
Hard disks are so inexpensive now that it's not difficult to justify buying a second hard disk to backup your data. You can get a new 40 GB or 60 GB hard disk for about US $50, maybe less if you're willing to shop around and look at used.
So, you've got a second hard disk. Here's how you can set up a daily backup. Open a terminal window such as Konsole or Xterm and go to superuser mode as root:
su
Make a directory for your second hard disk:
mkdir /backup
Use the vi text editor or open some other simple text editor and enter the following commands into a text file. (If you're using vi by typing "vi" to a command prompt, "I" will put you into Insert mode.)
umount /backup
mount -t ext3 /dev/hdb /backup
rsync -auvP /data/* /backup/
umount /backup
Save the text file as "dailybackup" (if you're using vi, hit Esc then type ":save ./dailybackup").
The above assumes that your second, backup hard disk is /dev/hdb and that your data is in the "/data" directory. If your backup hard disk is called something else, use that. Likewise, if your data is in your /home directory, use "/home/myuserid" instead of "/data".
Make your new backup script executable:
chmod a+x ./dailybackup
Test your backup script:
./dailybackup
The script should run and backup /data/* to /backup . Rsync only backs up incremental changes, so your dailybackup script should run very fast after the first time you run it.
Now, add your backup script to the daily cron job. This is a batch process that typically runs sometime during the early morning hours. Mine runs at 0400.
cp ./dailybackup /etc/cron.daily/
Now your data will be backed up daily to your second hard disk. Just remember to leave your system running overnight.
Next time I'll explain how to synchronise your desktop and notebook PCs using Rsync and Secure Shell (SSH). ยต