help: tar syntax

help: tar syntax

Post by aka.. » Wed, 27 Dec 2000 14:35:15



/home/net/stuff has lotsa good files i need to back up.  of course, i
need to leave the contents of /home/net/stuff _intact_ and in place.
currenly what i do is type "cp -r stuff stuffBkUp"

what i need to do is to get that same effect, but use compression.  that
is, instead of having directory "stuffBkup" i would like file
"stuffBkUp.tar" in its place.  and then, i would like to be able to
un-compress "stuffBkUp.tar" of course, which would create directory
"stuffBkUp." simple, right? ooh, when i uncompress "stuffBkUp.tar" can i
leave "stuffBkUp.tar" in place? so it would create directory "stuffBkUp"
and i would still have "stuffBkUp"?  (that last part isn't necesary, i
can just cp the file, i guess)

i have two unix books, but they must not be the right ones :(  please
help me

   thanks,

   aka007tarbaby

Sent via Deja.com
http://www.deja.com/

 
 
 

help: tar syntax

Post by aka007tarb.. » Wed, 27 Dec 2000 14:40:27


i tried to post this to comp.os.linux.help, but got some weird error.
this was just a test, i didn't expect it to really post!  anyhow, do
help me with the syntax, if you can

i'm forwarding this to deja, i guess:

News Server Error

A system error occurred when we tried to post your message to our news
server.

Cause: No valid newsgroups in "comp.os.linux.help"

and yet, i'm subscribed. imagine that.


this problem, and
we will do our best to help you out.

Sent via Deja.com
http://www.deja.com/

 
 
 

help: tar syntax

Post by Chris Boo » Wed, 27 Dec 2000 19:29:31



wrote on 26/12/2000 6:35:

Quote:> /home/net/stuff has lotsa good files i need to back up.  of course, i
> need to leave the contents of /home/net/stuff _intact_ and in place.
> currenly what i do is type "cp -r stuff stuffBkUp"

> what i need to do is to get that same effect, but use compression.  that
> is, instead of having directory "stuffBkup" i would like file
> "stuffBkUp.tar" in its place.  and then, i would like to be able to
> un-compress "stuffBkUp.tar" of course, which would create directory
> "stuffBkUp." simple, right? ooh, when i uncompress "stuffBkUp.tar" can i
> leave "stuffBkUp.tar" in place? so it would create directory "stuffBkUp"
> and i would still have "stuffBkUp"?  (that last part isn't necesary, i
> can just cp the file, i guess)

> i have two unix books, but they must not be the right ones :(  please
> help me

cd into /home/net and type

tar -czf stuffBkup.tar.gz stuff

This will put all the files into a tar archive and compress them with gzip.
If you wanted to use bzip2, use:

tar -cIf stuffBkup.tar.bz2 stuff

the 'z' was replaced with a capital letter i, not an l.

To extract the backup, cd into /home/net and type

tar -xzf stuffBkup.tar.gz (gzip)
tar -xIf stuffBkup.tar.bz2 (bzip2)

Good luck,
--
Chris

 
 
 

help: tar syntax

Post by Griff Miller I » Thu, 28 Dec 2000 13:14:28



> /home/net/stuff has lotsa good files i need to back up.  of course, i
> need to leave the contents of /home/net/stuff _intact_ and in place.
> currenly what i do is type "cp -r stuff stuffBkUp"

> what i need to do is to get that same effect, but use compression.  that
> is, instead of having directory "stuffBkup" i would like file
> "stuffBkUp.tar" in its place.  and then, i would like to be able to
> un-compress "stuffBkUp.tar" of course, which would create directory
> "stuffBkUp." simple, right? ooh, when i uncompress "stuffBkUp.tar" can i
> leave "stuffBkUp.tar" in place? so it would create directory "stuffBkUp"
> and i would still have "stuffBkUp"?  (that last part isn't necesary, i
> can just cp the file, i guess)

tar can be kind of confusing. First of all, tar does not compress
anything, unless you tell it to and you have a variant of tar that
can. If you are running Linux then your tar can probably compress
as well as, uh, tar. Just see the tar manpage and look for "compress" .
I've never actually used that option but it looks straightforward enough.
Actually, if it were me I'd use the option for gzip instead of compress.
It's similar.

Anyway, to answer one of your questions, when you create a tar file
it does not delete the files that contribute to the archive, again unless
you tell it to and you have a tar that knows how.

Similarly, when you "untar", the tarfile you are pulling files out of
does not go away or get altered in any way.

To back up your directory:

cd /home/net/stuff
tar cf /where/you/want/the/tarfile/to/live/stuffBkUp.tar .

(don't forget the trailing '.' )

Where you put stuffBkUp.tar can be anywhere. For sanity, maybe
it is best that it is not under /home/net/stuff .

To restore, try this:

cd /home/net/stuff
tar xpf /where/you/want/the/tarfile/to/live/stuffBkUp.tar

Note that I haven't specified any compression options - you
can add those later once you've looked at the manpage.

It is good practice to not use absolute paths when specifying
the files to be tarred, like this:

tar cf /some/place/file.tar /my/absolute/path   <--- bad

Instead, do something like:

cd /
tar cf /some/place/file.tar my/relative/path   <--- good

This is because you might want to relocate the files in the
tarfile elsewhere, and using an absolute path when you create
the tarfile complicates matters, and depending on which tar
you are using could even make it impossible to relocate the files.

Hope this helps.

--
Griff Miller II
Manager of Information Technology
Positron Corporation                "I need to be the owner of all of

 
 
 

1. help on tar command and its syntax.

Hi,
I want to create a tarball of a filesystem. I am specifically refering
to GNU Tar.

I was just going through the man'ual and found that there is one
option called
--atime-preserve

could someone elaborate more on this. I am a bit confused.
I mean is this supposed to be used during a tarball creation or a
tarball extraction.
and what exactly does that command really mean and do?

and what is this
--checkpoint
and what it really does?

--modification-time
??

--record-number
??

--verify
?? is is while creating or extracting??

Since the man and info are really very brief, I would prefer if the
explanation was a little more detailed.

2. problem with 4.1.1, apache 1.3.23

3. Help with tar syntax please

4. connectivity to bkbits.net?

5. Please help with tar syntax.

6. why I can't login Nis ?

7. Different syntax for 'tar' in linux and solaris.

8. .profile for X ?

9. tar syntax question

10. different syntax for "tar" in linux and solaris

11. Understanding the syntax for invoking tar

12. tar syntax

13. TAR syntax