How to restore a backup from a tgz file in linux

15,235

Solution 1

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.

Solution 2

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

Share:
15,235

Related videos on Youtube

Antonio Alimba
Author by

Antonio Alimba

Updated on September 18, 2022

Comments

  • Antonio Alimba
    Antonio Alimba almost 2 years

    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
    Felix Frank about 10 years
    While the info is not wrong per se, it does not pertain to the question directly.
  • Antonio Alimba
    Antonio Alimba about 10 years
    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.