LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-30-2009, 07:43 AM   #1
PeteWieland
LQ Newbie
 
Registered: Mar 2005
Location: North Wales UK
Distribution: Debian Squeeze
Posts: 15

Rep: Reputation: 0
Help with tar commands


Hi,

Using guides from various websites, I have backed up a directory (and its sub-directories) to tape using the following command:- (the folder 'media' is in the root)

Code:
tar -czf /dev/st0 /media/store
The command returned a message about stripping the leading slashes, and then went on to complete normally.

I now want to verify the backup, so I tried the following:-

Code:
tar -dlpzvf /dev/st /media/store
This, after reading the entire tape, returns:-

Code:
tar: /media/store: Not found in archive
I tried without the leading '/' (as the original backup said it had stripped it) and that returned "Warning: Cannot stat: No such file or directory" for every file name.

I know at least some of the files are there as

Code:
tar -tzf /dev/st0
starts a full directory listing from the tape.

How do I verify my backup? I can't restore the backup and check it that way as I don't have enough disk space.


[EDIT] The directory listing returns the full path without the leading / i.e "media/store/ARSF/Append.sql"

Last edited by PeteWieland; 11-30-2009 at 07:47 AM. Reason: Added extra info.
 
Old 11-30-2009, 08:36 AM   #2
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,453

Rep: Reputation: 447Reputation: 447Reputation: 447Reputation: 447Reputation: 447
Hi

The reason tar gives the warning when making the tar file with leading slashes, is that it could be a serious security problem. Let's say I did this:

tar -czf test.tgz /etc/passwd

Then I send the .tgz (or tape) to someone else. They will typically go to a directory, do tar -xzf to unpack it, and expect the files to be unpacked in the current directory.

If it instead wrote to /etc/passwd, weird things could happen. So it strips leading slashes.

The solution is simple. Instead of using leading / when using tar, go to the start and do the tar without any leading /.

cd / && tar -czf /dev/st0 media/store

cd / && tar -dlpzvf /dev/st media/store
 
1 members found this post helpful.
Old 11-30-2009, 09:01 AM   #3
PeteWieland
LQ Newbie
 
Registered: Mar 2005
Location: North Wales UK
Distribution: Debian Squeeze
Posts: 15

Original Poster
Rep: Reputation: 0
Thanks Guttorm for your very clear and concise answer.

Running the command from the root directory has solved the problem.
 
Old 11-30-2009, 08:34 PM   #4
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
You don't have to change to the root dir. tar -C / -dlpzf ... makes tar to go to the root dir before the operation. In your first post you wanted to compare from /dev/st instead of /dev/st0. I take it that was a typo.

jlinkels
 
  


Reply



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
Reviewing Tar commands with one key mvmoncayo Linux - Newbie 6 10-15-2009 12:08 PM
Create file using tar and ls commands Ejdaha Linux - Newbie 2 02-16-2009 08:55 AM
Differences between tar, cpio and dump commands diwakars Linux - Newbie 2 06-08-2008 02:26 PM
About tar and gzip commands satimis *BSD 2 05-29-2007 02:20 AM
tar Commands Orkie Linux - Software 7 07-27-2005 02:50 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:29 AM.

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
Open Source Consulting | Domain Registration