LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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 08-04-2008, 07:51 PM   #1
patoy
LQ Newbie
 
Registered: Jul 2008
Posts: 28

Rep: Reputation: 15
Tar Clarification


Hi! i just need clarification if this would be possible.

Suppose I have shell script in dir /root that will backup a dir in /usr/local/sample

would that be possible?

I have tried the command tar czf backup.tar.gz ../usr/local/sample but it will not work. same as tar czf backup.tar.gz /usr/local/sample doesn't work still. any workaround?
 
Old 08-04-2008, 08:15 PM   #2
hockeyman_102
Member
 
Registered: Apr 2006
Location: Washington
Distribution: Suse, CentOS, Ubuntu
Posts: 124

Rep: Reputation: 15
`tar cvzf backup.tar.gz ../usr/local/sample/` ?
`tar cvzf backup.tar.gz ../usr/local/sample/*` ?
 
Old 08-04-2008, 08:21 PM   #3
patoy
LQ Newbie
 
Registered: Jul 2008
Posts: 28

Original Poster
Rep: Reputation: 15
i got this working by the way: tar czf scripts.tar.gz ../scripts
tar gave this message: tar: Removing leading `../' from member names

would that be treated an error message or just a notification?

when i have checked tar file, it was complete.
 
Old 08-04-2008, 08:40 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,295

Rep: Reputation: 2358Reputation: 2358Reputation: 2358Reputation: 2358Reputation: 2358Reputation: 2358Reputation: 2358Reputation: 2358Reputation: 2358Reputation: 2358Reputation: 2358
Don't use relative paths. Tar removes leading stuff like that, inc leading /, so that the file can be loaded anywhere at the destination. ie no absolute paths in created file.
The simple/clean way is to cd to the dir just above the one you want to tar, then issue the cmd eg

cd /usr/local
tar czf backup.tgz sample
 
Old 08-04-2008, 08:51 PM   #5
patoy
LQ Newbie
 
Registered: Jul 2008
Posts: 28

Original Poster
Rep: Reputation: 15
oh! I see thanks for the clarification.
 
Old 08-04-2008, 10:33 PM   #6
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
Also look into the -C option (change directory) for tar
 
  


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
how can i decompress this tar.tar file? hmmm sounds new.. tar.tar.. help ;) kublador Linux - Software 14 10-25-2016 02:48 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
Diferance between rpm, tar, tar.gz, scr.tar, etc mobassir Linux - General 12 08-21-2003 06:30 AM


All times are GMT -5. The time now is 01:46 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration