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?

4 Answers 4


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.


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/....

  • 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. Jun 9, 2014 at 14:05

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


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.

  • 1
    While the info is not wrong per se, it does not pertain to the question directly. Jun 9, 2014 at 13:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.