Yofitech, LLC

Secure Remote Automated Backups using Free Software

Solutions / Yofitech, LLC News
Date: Jul 24, 2003 - 05:05 AM
In today's business environment, we often hear catch phrases like business continuity. All this means is disaster preparedness, or the ability to continue business after a major crisis like a fire or flood.

We run backups every night with a tool called Cron. After our backups run, we move a copy of our backups to an offsite location because we want to have our data physically somewhere else, just in case something unexpected happens to our place of business.

The further away the offsite location is from our place of business the better. If disaster strikes, the offsite location will less likely be affected if it is 3000 miles away.

The following tutorial will show you how to create automated backups with Cron and securely transfer those backups to a remote client with the help of dd and SSH. It is important to note that you will need to have User Based Public Key Authentication configured before proceeding with this tutorial. Please read our article on setting up User Based Public Key Authentication if you have not done so already.

Once User Based Public Key Authentication is working, proceed to set root's crontab by following the steps below.

Login as root and issue this command:

crontab -e

This will open up vi, a text editor. Type "i" to enter insert mode. On the first line type:

00 02 * * * updatedb

This will issue the command updatedb at 2:00 AM each night. This will update the slocate database, useful for searching for files and folders on your system.

The second line should read:

00 03 * * * mysqldump -A --add-drop-table > /home/charles/YofiTech.Com.sql

This will dump all the MySQL databases at 3:00 AM each night. It will place the dump in a file called YofiTech.Com.sql under the directory /home/charles.

The third, fourth and fifth lines should read:

00 05 * * * tar czvf - /root /home /var /etc | ssh ufs2.no-ip.org dd of=/home/buddy/YofiTech.Com/Mail.Yofitech.Com-Daily.tar.gz

00 04 * * fri tar czvf - /root /home /var /etc | ssh ufs2.no-ip.org dd of=/home/buddy/YofiTech.Com/Mail.Yofitech.Com-Weekly.tar.gz

00 01 1 * * tar czvf - /root /home /var /etc | ssh ufs2.no-ip.org dd of=/home/buddy/YofiTech.Com/Mail.Yofitech.Com-Monthly.tar.gz

The third line tars and gzips /root /home /var /etc into a file called Mail.Yofitech.Com-Daily.tar.gz each morning at 5:00 AM. It then uses SSH to securely transfer the file to the host ufs2.no-ip.org and places the file in the directory /home/buddy/YofiTech.Com. The fourth and fifth lines do the same thing except they run each Friday and the first day of each month respectively.

Please remember to set up User Based Public Key Authentication first and change the hostnames, file names and paths, and times to suit your own business needs.

Once you are satisfied with your file, save it. Hit the "esc" key to exit insert mode. Then type ":wq!" to write your changes to disk and quit. If you make a mistake type ":q!" and this will quit without writing your changes to disk.

You can check your crontab by issuing this command:

crontab -l

If all looks well, you are done. Now all you have to do is wait and check your backup file tomorrow to make sure it ran successfully. If it did, congratulations! You are now one step closer to ensuring business continuity by keeping a copy of your backups at a remote location!


This article comes from Yofitech, LLC
http://www.yofitech.com/

The URL for this story is:
http://www.yofitech.com/modules.php?op=modload&name=News&file=article&sid=13