LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   tar restore issues (https://www.linuxquestions.org/questions/linux-newbie-8/tar-restore-issues-4175502968/)

munir6 04-25-2014 09:53 AM

tar restore issues
 
Hi, I have taken a backup of the following file system (folder).

/usr/CM/HST

with this command

tar cpfvz /usr/LARGE/BKUP/hst_20140422.tar.gz *

Now I want to restore /usr/CM/HST into another redhat server at /usr/CM/HST and overwrite just HST folder and subfolders. When I am trying restore, the restored files are going in different place.

Could I get some guidelines how can I restore exactly into /usr/CM/HST and overwrite HST and their sub folders and files

Thanks

szboardstretcher 04-25-2014 10:12 AM

to clarify you did this:

Code:

cd /usr/CM/HST
tar cpfvz /usr/LARGE/BKUP/hst_20140422.tar.gz *

and you've tried untarring like this on another server

Code:

cp /usr/LARGE/BKUP/hst_20140422.tar.gz /usr/CM/HST
cd /usr/CM/HST
tar xvf hst_20140422.tar.gz

and it did not do what you expected?

munir6 04-25-2014 10:18 AM

Yes, I tried
cd /usr/CM/HST
tar xvf hst_20140422.tar.gz but it restored under /usr/CM/HST/HST

I would like to replace /usr/CM/HST from the backup.

szboardstretcher 04-25-2014 10:19 AM

Back out one dir?

Code:

cp /usr/LARGE/BKUP/hst_20140422.tar.gz /usr/CM/
cd /usr/CM
tar xvf hst_20140422.tar.gz


munir6 04-25-2014 10:29 AM

Thank you. I tried this one as well. Then it started restored subfolders under /usr/CM. I would like the full HST folder to be copied at /usr/CM.

I tried something like and this might be working:


Does this work (can this copy and replace files under HST):
cd /usr/CM
tar xvfz /usr/LARGE/BKUP//usr/LARGE/BKUP/hst_20140422.tar.gz HST

szboardstretcher 04-25-2014 10:43 AM

First, look in the tar to make sure you are getting the hierarchy the way you think you are.

Code:

tar tvf whatever.tar.gz
Then you can call it out more specifically like this, to extract HST to /usr/CM:

Code:

tar xvf whatever.tar.gz -C /usr/CM HST

munir6 04-25-2014 10:57 AM

Thank you very much, is this command for Red Hat.

szboardstretcher 04-25-2014 11:05 AM

Centos. It's a redhat clone, you should be ok there.

munir6 04-25-2014 12:32 PM

I listed the tar contents using $tar tvfz hst_20140422.tar.gz|more

drwxrwxr-x root/cmm 0 2010-06-14 10:59:37 BKUP/
drwxrwxr-x 1027/cmm 0 2010-10-06 09:00:37 cmmGO/
-rw-rw-r-- 1027/cmm 27 2010-10-06 09:00:37 cmmGO/.profile
drwxrwxr-x cmm/cmm 0 2007-06-13 11:04:23 DEVC/
-rw-rw-r-- cmm/cmm 1399808 2014-04-09 11:14:08 DEVC/D_USERCONTROL
-rw-rw-r-- cmm/cmm 603136 2014-04-09 11:26:12 DEVC/VOC
-rw-rw-r-- cmm/cmm 4096 2004-02-18 09:50:51 DEVC/D_VOC
drwxrwxr-x cmm/cmm 0 2013-03-06 07:52:00 DEVC/SAVEDLISTS/
-rw-rw-r-- cmm/cmm 203 2002-10-30 15:54:20 DEVC/SAVEDLISTS/HSTRELN$HSFPSTATUS000
-rw-rw-r-- cmm/cmm 126 2002-10-30 15:54:21 DEVC/SAVEDLISTS/HSTRELN$HSFMASTER000
-rw-rw-r-- cmm/cmm 19 2003-12-18 09:38:00 DEVC/SAVEDLISTS/SEL.NOTES1000
-rw-rw-r-- cmm/cmm 12 2003-07-25 10:43:10 DEVC/SAVEDLISTS/$POTAPPR_2000
-rw-rw-r-- cmm/cmm 386 2003-12-16 14:21:25 DEVC/SAVEDLISTS/$WLLOC4000
-rw-rw-r-- cmm/cmm 24 2002-12-04 14:04:07 DEVC/SAVEDLISTS/FORM.PHA22.B000
-rw-rw-r-- cmm/cmm 8 2002-11-04 15:40:21 DEVC/SAVEDLISTS/FORM.PEST12.B000
-rw-rw-r-- cmm/cmm 7 2003-12-10 17:45:28 DEVC/SAVEDLISTS/APL040000
-rw-rw-r-- cmm/cmm 1013 2003-01-09 11:00:11 DEVC/SAVEDLISTS/$POST.GL.5000

The BKUP, cmmGO, DEVC etc are subfolders under /usr/CM/HST

If the backup file is at /usr/LARGE/BKUP

Should I issue commands like this:
cd /usr/LARGE/BKUP
tar xvf whatever.tar.gz -C /usr/CM HST

Will the above restore files into /usr/CM/HST and overwrite?

szboardstretcher 04-25-2014 12:36 PM

In that case you would do:

Code:

tar xvf whatever.tar.gz -C /usr/CM/HST
What you are doing is saying:

Uncompress * to /usr/CM/HST

My other command would grab a DIRECTORY out of that list you have and uncomress it to a location.. e.g:

Code:

tar xvf whatever.tar.gz -C /usr/CM BKUP
Would uncompress the BKUP directory to /usr/CM/BKUP

Hope that helps. If not, if its confusing or just taking too long... you can always uncompress it to 'wherever' and copy its contents to the correct directory with rsync. E.g:

Code:

tar xvf whatever.tar.gz -C /tmp/whatever
rsync -varh /tmp/whatever/ /usr/CM/HST/

But i'd stay stick with it and figure it out, no use in needlessly creating extra steps :)


All times are GMT -5. The time now is 02:21 PM.