Unable to restore *.tar file

I tarred a directory to a different location. I then deleted the original directory.
Now I need to restore the directory, and I am unable to do so (The contents do not get restored). However, when I type tar -tvf <tarfile), the list of contents are displayed :

# tar -tvf lhs20170405.tar
rwx------ 146/20      0 Apr  5 00:01 2017 /home/lhs/lmon/
rwx------ 146/20      0 Apr 12 17:42 2013 /home/lhs/lmon/scripts/
rwx------ 146/20   4326 Sep  9 19:46 2010 /home/lhs/lmon/scripts/collect_db_mtv.sh
rwx------ 146/20   3684 Sep  9 19:46 2010 /home/lhs/lmon/scripts/collect_db_wal.sh
rwx------ 146/20  27590 Feb 10 18:45 2012 /home/lhs/lmon/scripts/collect_environment_data.sh
rwx------ 146/20  25139 Oct 26 23:21 2009 /home/lhs/lmon/scripts/collect_environment_data.sh.old
rwx------ 146/20   4081 Feb 16 19:52 2012 /home/lhs/lmon/scripts/collect_perf_data.sh
rwx------ 146/20    823 Feb 16 19:52 2012 /home/lhs/lmon/scripts/getosver.sh
rwx------ 146/20  27091 Feb 16 19:52 2012 /home/lhs/lmon/scripts/global_header
rwx------ 146/20    477 Dec  5 02:02 2008 /home/lhs/lmon/scripts/cron_driver.sh
rwx------ 146/20    859 Apr  2 18:31 2012 /home/lhs/lmon/scripts/longterm.sh
rwx------ 146/20    822 Oct 31 01:04 2012 /home/lhs/lmon/scripts/snapshot.sh
rw------- 146/20     49 Jan 13 01:09 2009 /home/lhs/lmon/scripts/crontab
rwx------ 146/20   1503 Feb 16 19:52 2012 /home/lhs/lmon/scripts/collect_scp.sh
rwx------ 146/20   4334 Sep  9 19:47 2010 /home/lhs/lmon/scripts/collect_db_mtv.old.sh
rwx------ 146/20   5662 Sep  9 19:47 2010 /home/lhs/lmon/scripts/collect_db_bes.sh
rwx------ 146/20  29668 Feb 10 18:45 2012 /home/lhs/lmon/scripts/collect_environment_data_new.sh
rw------- 146/20    121 Feb 16 19:52 2012 /home/lhs/lmon/scripts/crontab_15_min
rw------- 146/20    409 Mar 30 17:27 2012 /home/lhs/lmon/scripts/crontab_4_4_min
rwx------ 146/20    461 Feb 16 19:52 2012 /home/lhs/lmon/scripts/map_dsk.pl
rwx------ 146/20  24576 Feb 16 19:52 2012 /home/lhs/lmon/scripts/meminfo
rwx------ 146/20    795 Feb 16 19:52 2012 /home/lhs/lmon/scripts/reinit.sh
rwx------ 146/20    464 Feb 16 19:52 2012 /home/lhs/lmon/scripts/sadc.sh
rw------- 146/20    472 Mar 30 17:31 2012 /home/lhs/lmon/scripts/crontab_4_4_min_new
rw------- 146/20    300 Apr  3 20:23 2012 /home/lhs/lmon/scripts/adviser_disk.txt
rw------- 146/20    409 Mar 30 17:27 2012 /home/lhs/lmon/scripts/adviser_fs.txt
rw------- 146/20    804 Mar 30 17:27 2012 /home/lhs/lmon/scripts/adviser_global.txt
rw------- 146/20   1089 Mar 30 17:27 2012 /home/lhs/lmon/scripts/adviser_processes_all.txt
rw------- 146/20   3724 Mar 30 17:27 2012 /home/lhs/lmon/scripts/adviser_processes.txt
rwx------ 146/20    286 Mar 30 17:27 2012 /home/lhs/lmon/scripts/kill_glance.sh
rwx------ 146/20    697 Mar 30 17:27 2012 /home/lhs/lmon/scripts/reinit_arch_glance.sh
rwx------ 146/20    604 Mar 30 17:27 2012 /home/lhs/lmon/scripts/reinit_glance.sh
rwx------ 146/20   2531 Mar 30 17:27 2012 /home/lhs/lmon/scripts/run_glance.sh
rwx------ 146/20   3033 Mar 30 17:27 2012 /home/lhs/lmon/scripts/settings
rwx------ 146/20  72432 Apr  2 18:31 2012 /home/lhs/lmon/scripts/pss
rwx------ 146/20      0 Apr 12 17:42 2013 /home/lhs/lmon/output/
rw------- 146/20 4678316 Feb 10 18:45 2012 /home/lhs/lmon/output/L28db01_lhs.tar.gz
rwx------ 146/20      0 Apr 12 17:42 2013 /home/lhs/lmon/bin/
rwx------ 146/20 1196964 Mar 30 16:58 2012 /home/lhs/lmon/bin/awk
rwx------ 146/20 319488 Mar 30 16:58 2012 /home/lhs/lmon/bin/awk_32
rwx------ 146/20 1196964 Mar 30 16:58 2012 /home/lhs/lmon/bin/gawk
rwx------ 146/20 319488 Mar 30 16:59 2012 /home/lhs/lmon/bin/gawk_32
rwx------ 146/20 167936 Mar 30 16:59 2012 /home/lhs/lmon/bin/gmake
rwx------ 146/20 1155072 Mar 30 16:59 2012 /home/lhs/lmon/bin/gpg
rwx------ 146/20 181880 Mar 30 16:59 2012 /home/lhs/lmon/bin/gzip
rwx------ 146/20 376832 Mar 30 16:59 2012 /home/lhs/lmon/bin/screen
rwx------ 146/20 282624 Mar 30 16:59 2012 /home/lhs/lmon/bin/tar
rwx------ 146/20 118784 Mar 30 16:59 2012 /home/lhs/lmon/bin/unzip
rwx------ 146/20    475 Mar 30 16:59 2012 /home/lhs/lmon/bin/sed
rwx------ 146/20 196608 Mar 30 16:59 2012 /home/lhs/lmon/bin/sed_32
rwx------ 146/20 481628 Mar 30 16:59 2012 /home/lhs/lmon/bin/sed_64
rwx------ 146/20    209 Mar 30 16:59 2012 /home/lhs/lmon/bin/sed_script
rwx------ 146/20    413 Mar 30 16:59 2012 /home/lhs/lmon/bin/sed.sh
rwx------ 146/20      0 Apr  5 00:01 2017 /home/lhs/lmon/log/
rw-r--r-- 146/20 73216498 Apr  3 23:58 2017 /home/lhs/lmon/log/L28db01_170403.log
rw-r--r-- 146/20 66447508 Apr  5 21:12 2017 /home/lhs/lmon/log/L28db01_170405.log
rw-r--r-- 146/20  12753 Apr  4 00:00 2017 /home/lhs/lmon/log/L28db01_170404.sar
rw-r--r-- 146/20 67980522 Apr  4 23:58 2017 /home/lhs/lmon/log/L28db01_170404.log
rw-r--r-- 146/20  11933 Apr  5 00:00 2017 /home/lhs/lmon/log/L28db01_170405.sar
rw-r--r-- 146/20 68573040 Apr  5 21:12 2017 /home/lhs/lmon/sadc.dat
rwx------ 146/20      0 Apr 12 17:43 2013 /home/lhs/lmon/sarcheck/
rwx------ 146/20    592 Mar 12 21:37 2012 /home/lhs/lmon/sarcheck/deploy.sh
rwx------ 146/20    467 Mar 12 21:12 2012 /home/lhs/lmon/sarcheck/ps1.sh
rwx------ 146/20    382 Apr  2 16:26 2012 /home/lhs/lmon/sarcheck/ps2.sh
rwx------ 146/20  69632 Mar  9 00:15 2012 /home/lhs/lmon/sarcheck/schpagent
rwx------ 146/20    354 Mar 12 21:13 2012 /home/lhs/lmon/sarcheck/vg1.sh
rwx------ 146/20  61440 Mar  9 00:15 2012 /home/lhs/lmon/sarcheck/vgparse
rwx------ 146/20      0 Apr  5 00:00 2017 /home/lhs/lmon/sarcheck/ps/
rw-r--r-- 146/20 39612541 Apr  2 23:50 2017 /home/lhs/lmon/sarcheck/ps/20170402
rw-r--r-- 146/20 6117137 Mar 27 23:50 2017 /home/lhs/lmon/sarcheck/ps/20170327.gz
rw-r--r-- 146/20 5954950 Mar 28 23:50 2017 /home/lhs/lmon/sarcheck/ps/20170328.gz
rw-r--r-- 146/20 5908942 Mar 26 23:50 2017 /home/lhs/lmon/sarcheck/ps/20170326.gz
rw-r--r-- 146/20 32940032 Apr  3 20:40 2017 /home/lhs/lmon/sarcheck/ps/20170403
rw-r--r-- 146/20 30253056 Apr  4 19:20 2017 /home/lhs/lmon/sarcheck/ps/20170404
rw-r--r-- 146/20 30261054 Apr  5 21:10 2017 /home/lhs/lmon/sarcheck/ps/20170405
rw-r--r-- 146/20 6358554 Apr  1 23:50 2017 /home/lhs/lmon/sarcheck/ps/20170401.gz
rw-r--r-- 146/20 5939881 Mar 25 23:50 2017 /home/lhs/lmon/sarcheck/ps/20170325.gz
rw-r--r-- 146/20 6233255 Mar 29 23:50 2017 /home/lhs/lmon/sarcheck/ps/20170329.gz
rw-r--r-- 146/20 6140091 Mar 30 23:50 2017 /home/lhs/lmon/sarcheck/ps/20170330.gz
rw-r--r-- 146/20 6303808 Mar 31 23:50 2017 /home/lhs/lmon/sarcheck/ps/20170331.gz
rw------- 146/20    153 Mar 12 21:50 2012 /home/lhs/lmon/sarcheck/crontab.sarcheck
rw------- 146/20  38532 Mar 23 22:08 2012 /home/lhs/lmon/sarcheck/vgparse.out
rwx------   0/3      0 Apr  5 21:12 2017 /archive/
#

What is the problem here?

Hi,

What actually goes wrong when you try to extract the tarball ? You say the contents do not get restored - but what actually does happen ? Is there an error, or anything else out of the ordinary ? You'll have to provide a bit more info regarding what is actually going wrong here before anyone can assist further.

Just guessing - tar usually removes leading \ when archiving, unless told otherwise. Is it possible that your restore ends up just below the cwd?

Just guessing - tar usually removes leading  \  when archiving, unless told otherwise. Is it possible that your restore ends up just below the cwd?

Did you mean leading

/

?

About the output from the tarring :
I just ran the command :

# cd <tar file directory>
# tar -xvf lhs20170405.tar /home/lhs

Then there was nothing.It just ended with a prompt without any message/error.
And when I checked the /home/lhs the folder was still not there.
Even performing a bdf /home still showed same usage as before the tarring was done. (6%).

That is only the case for GNU tar AFAIK... Regular tar's will happily oblige and store the leading slash. That is why one usually creates a tar with a relative path from the / directory..

--
@OP:
Try using a chrooted environment...

Or try removing the leading slash by using POSIX compliant pax , which should also be available on your system :

pax -r -s '|^/||' < tarfile

First cd to the directory where you want the tree to be created, like you would do with tar ..

Hi,

I think I can sort of replicate this on Solaris, using the SunOS native tar rather than GNU tar (which handles this fine).

As counter-intuitive as it might seem, try syntax like this:

tar -xvf lhs20170405.tar home/lhs

So actually leaving off the initial / basically. It will then extract it underneath wherever you are, and you can move it in to place.

Generally leading / 's in tar archives are not a good idea. GNU tar automatically strips them, as RudiC says; it seems SunOS tar (and I'd also guess HP-UX tar as well, by logical extension) doesn't, and will actually create an archive with them in it.

Anyway, try that, and see how you go.

Different OS's implement tar slightly differently.

With the information provided I'm still guessing but......

Just see what happens if you list without entering the minus.....

# tar tvf lhs20170405.tar

and if that lists okay then try

# tar xvf lhs20170405.tar

again without the minus.

Anyway you should be able to tell if it is actually extracting because (a) it will be slower than just listing, and (2) the disk activity light(s) will be reallt flashing whilst it's writing the files down. If you do see a difference in the two operations then you need to go find where tar has extracted the files to.

---------- Post updated at 11:32 AM ---------- Previous update was at 11:19 AM ----------

And regarding your post#4, if you use the 'v' (verbose) option on the extraction command line, all files will be listed as they are extracted. Therefore, I would say, no output indicates no extraction occurring.

You didnt say how you created your tar file, what I see is in your -tvf is that it is with absolute path and so when restoring it will want to go exactly there so you cannot decide on where you want to extract, for that you would have to create an archive using relative path eg ./...