Profile Facebook Twitter My Space Friendster Friendfeed You Tube
Kompas Tempo Detiknews
Google Yahoo MSN
Blue Sky Simple News Simple News R.1 Simple News R.2 Simple News R.3 Simple News R.4

Posts Recentes

Tuesday, October 14, 2008 | 12:28 PM | 0 Comments

Establishing Automatic System Backups in Unix

Are you a system administrator that needs to do system backups? Database backups? Maybe this will help.


Being that I am a novice system administrator, I thought it would be a good idea to post about my task accomplishments in this blog. Here is the first of many. (This is a conceptual model only. This posts lacks specifics. This post is merely intended to reinforce the concepts I learned while performing this task. I hope it helps you too.)

For system administrators, it is important to back up the systems that is necessary for your company to operate. I will use system1 as the system that needs to be backed up, and system2 as the computer that system1 will be writing to. To back up data between to Unix FreeBSD systems do the following:

First you have to use: ssh-keygen -t dsa on system1 in order to generate the key pair used for authentication so that one system may write to a file on another system without human intervention. Once the key is made you have to save it in a file where it can be found when needed by the system. You can save them in /home/user/.ssh/id_dsa .

Next you have to make sure that same key is on system2 in the same /home/user/.ssh/id_dsa directory. You can do this by first changing your current directory to where you intend to save the key on system2: cd /home/user/.ssh/id_dsa .

Next you have to make sure that same key is on system2 in the same /home/user/.ssh/id_dsa directory. You can do this by first changing your current directory to where you intend to save the key on system2: cd /home/user/.ssh/id_dsa .

Then, you must put system2 into the known_hosts file on system1, and put system1 into the known_hosts file on system2

Now you need to check to make sure that everything you just did actually works. To do this you need to try to ssh from one system to another. You should not be asked for a password. If you are asked for a password, you did something wrong.

Now that you have set up access between system1 and system2, the next step is to set up the actual backup process. I will use file1 for the file on system1, and file2 for the location on system2 where file1 will be written to.

First you create a file that will contain the commands that system1 is to execute to perform the writing portion of the backup. I called this file backup.sh. You generally want backup.sh to be in /usr/local/bin because that directory is in everyone’s PATH, avoiding any permissions issues. I will use directory1 for the directory on system1 that file1 lies in. As you probably guessed, i will use directory2 for the name of the directory on system2 that file2 lies in. Here is what the contents of your backup.sh file should resemble:

#/bin/sh cd /usr/local/directory1 tar cvf /tmp/system1.file1 * scp file1 system2:/directory2/file2
exit

Finally you must place an entry into the crontab to schedule the frequency of the backup. Here is what your crontab should look like:

0 14 * * * /usr/local/bin/backup.sh >/directory2/file2 2>&1

And voila! your automatic backup between 2 FreeBSD systems should be complete!

0 comments:

 
Copyright © 2010 - All right reserved | Template design by Herdiansyah Hamzah | Published by Jurnalborneo.com
Proudly powered by Blogger.com | Best view on mozilla, internet explore, google crome and opera.