LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-25-2014, 09:53 AM   #1
munir6
LQ Newbie
 
Registered: Apr 2014
Posts: 5

Rep: Reputation: Disabled
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
 
Old 04-25-2014, 10:12 AM   #2
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,211

Rep: Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612
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?
 
Old 04-25-2014, 10:18 AM   #3
munir6
LQ Newbie
 
Registered: Apr 2014
Posts: 5

Original Poster
Rep: Reputation: Disabled
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.
 
Old 04-25-2014, 10:19 AM   #4
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,211

Rep: Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612
Back out one dir?

Code:
cp /usr/LARGE/BKUP/hst_20140422.tar.gz /usr/CM/
cd /usr/CM
tar xvf hst_20140422.tar.gz
 
Old 04-25-2014, 10:29 AM   #5
munir6
LQ Newbie
 
Registered: Apr 2014
Posts: 5

Original Poster
Rep: Reputation: Disabled
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
 
Old 04-25-2014, 10:43 AM   #6
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,211

Rep: Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612
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
 
Old 04-25-2014, 10:57 AM   #7
munir6
LQ Newbie
 
Registered: Apr 2014
Posts: 5

Original Poster
Rep: Reputation: Disabled
Thank you very much, is this command for Red Hat.
 
Old 04-25-2014, 11:05 AM   #8
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,211

Rep: Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612
Centos. It's a redhat clone, you should be ok there.
 
Old 04-25-2014, 12:32 PM   #9
munir6
LQ Newbie
 
Registered: Apr 2014
Posts: 5

Original Poster
Rep: Reputation: Disabled
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?
 
Old 04-25-2014, 12:36 PM   #10
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,211

Rep: Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612
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

Last edited by szboardstretcher; 04-25-2014 at 12:39 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
More tar issues - listing files in a single tar from a multivolume borks Thymox Linux - Software 4 09-23-2009 07:48 PM
Restore with tar activeq Linux - Software 2 01-09-2007 06:39 AM
BackUp & Restore with TAR (.tar / .tar.gz / .tar.bz2 / tar.Z) asgarcymed Linux - General 5 12-31-2006 02:53 AM
tar | ssh (tar > .tar) syntax issues EarlMosier Linux - Software 6 12-21-2006 12:28 AM
tar/restore questions solex Linux - General 5 09-01-2004 02:03 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:26 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration