cancel
Showing results for 
Search instead for 
Did you mean: 

recovering a single file

SOLVED
Go to solution
kunjuttan
Super Advisor

recovering a single file

how can we able to recover a single file with frecover and tar?
20 REPLIES
Pete Randall
Outstanding Contributor

Re: recovering a single file

man tar
man frecover


Pete

Pete
R.K. #
Honored Contributor

Re: recovering a single file

Hi Dipesh,

To list files in TAR:
# tar -tvf

To recover files from TAR:
# tar -xvf

Don't fix what ain't broke
rariasn
Honored Contributor
kunjuttan
Super Advisor

Re: recovering a single file

"# tar -xvf "
But with this can we able to recover a single file?
R.K. #
Honored Contributor
Solution

Re: recovering a single file

Yes..

# tar -xvf

OR

# tar -xvf

tarfile - name of tar archive

destination - where you want the file to be extracted (this is optional argument)

path_of_file_to_be_recovered_as_in_tar - When you do a "tar -tvf <>" command, you can see the path of the file, it might be relative or might be absolute
Don't fix what ain't broke
Dennis Handly
Acclaimed Contributor

Re: recovering a single file

>tar -xvf

You can of course toss tar and use pax(1) instead: (or use GNU tar)
pax -r -v -f '-s:/path-prefix::'

>R.K.: destination - where you want the file to be extracted (this is optional argument)

What tar is this? There are no optional arguments "destination" arguments like this.
R.K. #
Honored Contributor

Re: recovering a single file

@ Dennis
>>There are no optional arguments "destination" arguments like this.

Thanks for correction.

/tmp
# ll ioscan*
ioscan* not found

/tmp
# tar -xvf sysinfo.tar /home ioscan.txt
x ioscan.txt, 5231 bytes, 11 tape blocks

/home
# ll ioscan*
ioscan* not found

/tmp
# ll ioscan*
-rw------- 1 root sys 5231 Dec 19 00:38 ioscan.txt


There are NO arguments for "destination" in tar.
Don't fix what ain't broke
kunjuttan
Super Advisor

Re: recovering a single file

Thanks.But here what /home means?
rariasn
Honored Contributor

Re: recovering a single file

Hi,

All directories fall under the topmost root directory, which is denoted by a slash (/). When you use HP-UX, you are working in a directory called the current working directory. And when you log in, HP-UX places you in your home directory.

Rgs,
kunjuttan
Super Advisor

Re: recovering a single file

Thanks,But that I know.I want to know why it is using with the tar command as we are extracting to /tmp directory as mentioned.
rariasn
Honored Contributor

Re: recovering a single file

kunjuttan
Super Advisor

Re: recovering a single file

Thank you sir.But its not that clear.
kunjuttan
Super Advisor

Re: recovering a single file

Thank you sir,But it is not that clear.I mean

"tmp
# tar -xvf sysinfo.tar /home ioscan.txt"

Here ioscan.txt is extracting from sysinfo.tar to /tmp.It is fine.But why /home is there in command line?
rariasn
Honored Contributor

Re: recovering a single file

Hi,

#
# pwd

/tmp

/tmp <-- working directory where is sysinfo.tar.

# tar -xvf sysinfo.tar /home ioscan.txt"

Here ioscan.txt is extracting from sysinfo.tar to /home.

rgs,

R.K. #
Honored Contributor

Re: recovering a single file

In /tmp, ioscan.txt is NOT present:
/tmp
# ll ioscan*
ioscan* not found
-----------------
Ran command to extract ioscan.txt to /home
/tmp
# tar -xvf sysinfo.tar /home ioscan.txt
x ioscan.txt, 5231 bytes, 11 tape blocks

-----------------
BUT IN /home, ioscan.txt IS STILL NOT PRESENT

/home
# ll ioscan*
ioscan* not found

-----------------
INSTEAD IT GOT EXTRACT IN /TMP (FROM WHERE WE RAN "TAR -XVF" ABOVE)

/tmp
# ll ioscan*
-rw------- 1 root sys 5231 Dec 19 00:38 ioscan.txt

-----------------
So............
There are no optional arguments "destination" arguments like this.

Don't fix what ain't broke
R.K. #
Honored Contributor

Re: recovering a single file

Depends how you are backing up using tar.

From the link mentioned earlier in this thread:

"Absolute path means specifying the ENTIRE path to the directory you want to back up. When you restore this it will be restored to the SAME EXACT path."

If you back up individual directories using tar...you will be restoring it only in CURRENT directory (from where you are running 'tar -xvf").




Don't fix what ain't broke
Steven Schweda
Honored Contributor

Re: recovering a single file

> If you back up individual directories using
> tar... [...]

"individual" has nothing to do with it. The
difference is between a path to a file (or
directory) which begins with a slash ("/")
and one which does not.

> Thanks.But here what /home means?

It's a mystery to me, too. Perhaps he still
thinks that his "" suggestion
made some sense, which it did not.

> What tar is this? There are no optional
> arguments "destination" arguments like
> this.

Listen to Mr. Handly.

> To list files in TAR:
> # tar -tvf

That part makes some sense. If we could see
what it says for the file which you'd like to
restore, then you might get some more
specific suggestions on how to extract it
(and put it where you'd like it).
Dennis Handly
Acclaimed Contributor

Re: recovering a single file

>But here what /home means?

That was R.K.'s proof that he was wrong about a "destination" in tar.

>Steven: Perhaps he still thinks that his "" suggestion made some sense,

He probably should have said that he was admitting he made a mistake more clearly and the example was proof. I.e. add more comments in the script. :-)


R.K. #
Honored Contributor

Re: recovering a single file

Hi Again,

MORE CLEARLY THIS TIME..

> But why /home is there in command line?
Presence of /home do NOT make any sense as there is NO option in tar command to specify folder.
See my example above, which shows that even after specifying /home, the file 'ioscan.txt' got extracted in /tmp (from where we ran 'tar -xvf..').


> Perhaps he still thinks that his "" ...[...]
This is what I tried to explain with an example that suggestion do NOT make any sense.

Hope I make it clear this time :-)
Don't fix what ain't broke
kunjuttan
Super Advisor

Re: recovering a single file

thanks gurus..I got it..