2

How can i restore from a backup.tgz file generated from another linux server on my own server? I tried the command the following command:

tar xvpfz backup.tgz -C /

The above command worked, but it replaced the existing system files which made my linux server not to work properly.

How can i restore without running into trouble?

Felix Frank
  • 3,063
  • 1
  • 15
  • 22
Antonio Alimba
  • 23
  • 1
  • 1
  • 3

4 Answers4

5

Unless otherwise specified The tar utility will extract files into the original tree within the current directory so for example in you are in /home/antonio/recovery and you issues the command

tar xvpfz backup.tgz

the files would be recovered into /home/antonio/recovery...

If you use the -C option this tells tar to change directory and to extract the files into a tree rooted there e.g.

 tar xvpfz backup.tgz -C /tmp 

would tell tar to change to /tmp and extract the files into /tmp/....

user9517
  • 114,104
  • 20
  • 206
  • 289
  • i understand the tar utility very well, but in a situation whereby i want to recover a backup from another redhat linux server to my redhat linux server, i run into problem, maybe because our system properties. How do i recover the backup.tgz to my "/" without running into trouble. – Antonio Alimba Jun 09 '14 at 14:05
2

You can use --skip-old-files command to tell tar not to overwrite existing files.

You could still run into problem with the backup files, if the software versions are different between the two servers. Some data file structure changes might have happeneed, and things might stop working.

A more refined backup process should be developed.

Tero Kilkanen
  • 34,499
  • 3
  • 38
  • 58
0

Tip: Maybe you don't want to restore everything, just a file or a directory.

Use this command to view the contents of the backup:

tar -tzf backup.tgz | grep toys.db (or whatever you are looking for)

and suppose it returns something like this: ./home/myname/play/toys.db

To restore it you could: tar -xvpzf backup.tgz -C /tmp ./home/myname/play/toys.db

-2

ascii files can be recovered by

  • go to single user mode. grep -ib "filename'
  • /dev/whateverpartion_name > /tmp/somefile

view /tmp/somefile and see what you want to copy over from /dev/ to original location.

if you are on ext2 mount, may be you can try recover command.

my two penny advice for future :please always read man page for command and arguments before you actually run.

akash
  • 333
  • 1
  • 10