LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Restore backup files (https://www.linuxquestions.org/questions/linux-newbie-8/restore-backup-files-657849/)

nawuza 07-23-2008 11:50 PM

Restore backup files
 
hello..i am done backing up my desire files by tar'ing' it.
here are the files that i backup:

/var/lib/mysql/
/var/www/html/
/etc/named.conf
/var/named/
/etc/httpd/conf/httpd.conf

i need to back this files into another same linux box. I have an idea of writing a script which extract the files and link it with the one that are running on the other box.Didnt get what i mean?!ok let me put it this way.LINUX1 have apache,bind,mysql running on it.Then i tar all files that are related to those thing.then i copy the tarball into LINUX2 which have the same architecture. what i am going to do after that is extract the file into a directory called backup.then i link the original apache,bind,mysql related files in LINUX2 to the one in the backup.
understand?!..hope you understand lads..
can anyone give an idea hw to do it?

chrism01 07-24-2008 01:51 AM

If box boxes are the same distro/ver and layout, then rsync is your answer.
Note that if both boxes will be running at the same time 'live', then you may need to do a few edits on box 2 before starting those services.

nawuza 07-24-2008 02:29 AM

ok..what if i want to use ln -s [source] [destination]?!
i extract the tarball into a folder name folder1.then i link the file in it which is :

/var/lib/mysql/
/var/www/html/
/etc/named.conf
/var/named/
/etc/httpd/conf/httpd.conf

i link it with the original one running the the 2nd machine.but i am confuse whether the command looks like this:
Code:

ln -s /folder1/var/lib/mysql/ /var/lib/mysql/
or like this:
Code:

ln -s /var/lib/mysql/ /folder1/var/lib/mysql/

storkus 07-24-2008 06:38 AM

The man page for "ln" IS a bit confusing, but the idea is "ln -s <source> <destination> where -s makes a symlink (normally what you want), source is the ACTUAL file you want pointed AT, and destination is the name of the symlink AKA the pointer.

So as an example in my /usr/src directory I have "linux-2.6.23" and I want to make a symlink "linux" to it. The command is:

ln -s /usr/src/linux-2.6.23 /usr/src/linux

In other words, it's sort of backwards from what you would think it should work. I can also tell you from experience it's a VERY good idea to feed ln the full directory tree of both source and destination.

I hope that helps.

Mike

trickykid 07-24-2008 09:58 AM

Using symlinks is not a good idea, not a good idea. If these are going to be files cause you wanted to make an identical server by backing up on one machine and then restoring on another, it's better that these files replace the existing ones in the actual location, not with symlinks.

DONT USE SYMLINKS!

nawuza 07-24-2008 08:09 PM

Quote:

Originally Posted by trickykid (Post 3225015)
Using symlinks is not a good idea, not a good idea. If these are going to be files cause you wanted to make an identical server by backing up on one machine and then restoring on another, it's better that these files replace the existing ones in the actual location, not with symlinks.

DONT USE SYMLINKS!

replace the file is much better?!..what if i still want to use ln command,instead of using symlinks,is there other command that i can use to link the back up file to the originall file?

nawuza 07-24-2008 08:18 PM

i try testing the ln command.in the same directory i create 2 text file called one.txt and two.txt.

then i link the two files
Code:

ln -s one.txt two.txt
the i got ln: creating symbolic link `two.txt': File exists

why can i replace the existing two.txt file to be a symlinks?!

jschiwal 07-24-2008 08:35 PM

The "ln" command has a manpage, or you can enter "ln --help" for the answer.

However, did you even read trickykid's post?

If the original file becomes damaged, then the link on the other will become bad as well. Plus you are using a link to a networked connection inplace of a file. What if the network goes down? What if the file is read before the network is ready?

You probably want to either use rsync as already suggested to keep the backup server synced to the primary. You could instead use tar to extract the backed up files from the first server and extract these files on the backup server.

Even using rsync, you still want to perform frequent backups. Using either method, if there is a problem on the active server you are replicating the same problem on the second. You may need to restore a file from a previous archive.

nawuza 07-24-2008 10:12 PM

Quote:

Originally Posted by nawuza (Post 3224466)
hello..i am done backing up my desire files by tar'ing' it.
here are the files that i backup:

/var/lib/mysql/
/var/www/html/
/etc/named.conf
/var/named/
/etc/httpd/conf/httpd.conf

i know the sequences of using ln. still i want to do it cause i want to learn.

the problem is below..i cannot link between the original and the backup..

Code:

[root@localhost mysql]# ln -s CL /backup/2008-07-26/var/lib/mysql/CL
ln: creating symbolic link `/backup/2008-07-26/var/lib/mysql/CL/CL': File exists


jschiwal 07-24-2008 10:23 PM

You already have a CL file on the backup server so the command fails.

ynilesh 07-25-2008 05:51 AM

Remove already linked file first and then link again. It can be done.

One Question :
Are you going to use your second hosts as a backup server. So if your LINUX1 box goes down you can anytime come up with LINUX2. ?

- nilesh.


All times are GMT -5. The time now is 02:38 AM.