tar syntax question

tar syntax question

Post by vervoo » Tue, 12 Feb 2002 20:40:10



Hi,

I'm trying to backup an AIX box using the following command:

find / -print | grep -v /netrs1/backup | tar cfL - >
/netrs1/backup/netrs1.tar 2> /netrs1/backup/netrs1.err

where netrs1 is the hostname, and /netrs1/backup is mounted on a remote box.

Anyway, what I'm trying to do is run tar on the / directory but exclude
directory /netrs1/backup. But the command I typed above doesn't work.
Could someone help me with the syntax please? (I'm using the AIX tar).

Thanks,

JS.

 
 
 

tar syntax question

Post by Miljenko Jandr » Wed, 13 Feb 2002 00:45:34




Quote:>Hi,

>I'm trying to backup an AIX box using the following command:

>find / -print | grep -v /netrs1/backup | tar cfL - >
>/netrs1/backup/netrs1.tar 2> /netrs1/backup/netrs1.err

I suspect you should do "tar cLf -", not "tar cfL -". Filename (in
this case "-") should follow "f".

mj

Quote:

>where netrs1 is the hostname, and /netrs1/backup is mounted on a remote box.

>Anyway, what I'm trying to do is run tar on the / directory but exclude
>directory /netrs1/backup. But the command I typed above doesn't work.
>Could someone help me with the syntax please? (I'm using the AIX tar).

>Thanks,

>JS.


 
 
 

tar syntax question

Post by vervoo » Wed, 13 Feb 2002 18:24:41


If I try :

find / -print | grep -v /netrs1/backup | tar cLf
/netrs1/backup/netrs1.tar 2> /netrs1/backup/netrs1.err

I get:

tar: cannot open /netrs1/backup/netrs1.tar




>>Hi,

>>I'm trying to backup an AIX box using the following command:

>>find / -print | grep -v /netrs1/backup | tar cfL - >
>>/netrs1/backup/netrs1.tar 2> /netrs1/backup/netrs1.err

> I suspect you should do "tar cLf -", not "tar cfL -". Filename (in
> this case "-") should follow "f".

> mj

>>where netrs1 is the hostname, and /netrs1/backup is mounted on a remote box.

>>Anyway, what I'm trying to do is run tar on the / directory but exclude
>>directory /netrs1/backup. But the command I typed above doesn't work.
>>Could someone help me with the syntax please? (I'm using the AIX tar).

>>Thanks,

>>JS.

 
 
 

tar syntax question

Post by Gerhard A. Bartosc » Wed, 13 Feb 2002 22:57:43


Your right syntax should be:
find / -print | grep -v /netrs1/backup | tar cf  /netrs1/backup/netrs1.tar
2> /netrs1/backup/netrs1.err
You does not need -L in this case.
To see what is backed up insert maybe v (tar cvf).

--
Kind regards

Gerhard A. Bartosch

iT Austria
Vienna

This opinion is mine and not necessarily that of my employer.
No guarantees whatsoever.



> If I try :

> find / -print | grep -v /netrs1/backup | tar cLf
> /netrs1/backup/netrs1.tar 2> /netrs1/backup/netrs1.err

> I get:

> tar: cannot open /netrs1/backup/netrs1.tar




> >>Hi,

> >>I'm trying to backup an AIX box using the following command:

> >>find / -print | grep -v /netrs1/backup | tar cfL - >
> >>/netrs1/backup/netrs1.tar 2> /netrs1/backup/netrs1.err

> > I suspect you should do "tar cLf -", not "tar cfL -". Filename (in
> > this case "-") should follow "f".

> > mj

> >>where netrs1 is the hostname, and /netrs1/backup is mounted on a remote
box.

> >>Anyway, what I'm trying to do is run tar on the / directory but exclude
> >>directory /netrs1/backup. But the command I typed above doesn't work.
> >>Could someone help me with the syntax please? (I'm using the AIX tar).

> >>Thanks,

> >>JS.

 
 
 

tar syntax question

Post by Miljenko Jandr » Thu, 14 Feb 2002 00:12:20


Now I see what you are trying to do.... Sorry, I misunderstood you the
first time.

Try one of these two:

1) find / -print | grep -v /netrs1/backup | tar cL -
-f /netrs1/backup/netrs1.tar 2> /netrs1/backup/netrs1.err

(there is cL <space> - <space> -f <filename>)

or if that doesn't work try:

2) tar -cf /netrs1/backup/netrs1.tar
`find / -print | grep -v /netrs1/backup`  2> /netrs1/backup/netrs1.err

(of course, this is one line. The "find" portion is in backquotes)

I am not sure if "L" accepts "-" as an argument, so 1) might not work.
However, 2) should be OK.

Out of curiosity: you are trying to tar the whole system starting at
root into a single tar file? Why?

mj



>If I try :

>find / -print | grep -v /netrs1/backup | tar cLf
>/netrs1/backup/netrs1.tar 2> /netrs1/backup/netrs1.err

>I get:

>tar: cannot open /netrs1/backup/netrs1.tar




>>>Hi,

>>>I'm trying to backup an AIX box using the following command:

>>>find / -print | grep -v /netrs1/backup | tar cfL - >
>>>/netrs1/backup/netrs1.tar 2> /netrs1/backup/netrs1.err

>> I suspect you should do "tar cLf -", not "tar cfL -". Filename (in
>> this case "-") should follow "f".

>> mj

>>>where netrs1 is the hostname, and /netrs1/backup is mounted on a remote box.

>>>Anyway, what I'm trying to do is run tar on the / directory but exclude
>>>directory /netrs1/backup. But the command I typed above doesn't work.
>>>Could someone help me with the syntax please? (I'm using the AIX tar).

>>>Thanks,

>>>JS.

 
 
 

tar syntax question

Post by vervoo » Thu, 14 Feb 2002 00:20:43


I've running a test with this command on the tmp directory and when I
issue the command below (with the v) I can see nothing gets tarred up.
My two files netrs1.tar and netrs1.err are both empty.

> Your right syntax should be:
> find / -print | grep -v /netrs1/backup | tar cf  /netrs1/backup/netrs1.tar
> 2> /netrs1/backup/netrs1.err
> You does not need -L in this case.
> To see what is backed up insert maybe v (tar cvf).

> --
> Kind regards

> Gerhard A. Bartosch

> iT Austria
> Vienna

> This opinion is mine and not necessarily that of my employer.
> No guarantees whatsoever.



>>If I try :

>>find / -print | grep -v /netrs1/backup | tar cLf
>>/netrs1/backup/netrs1.tar 2> /netrs1/backup/netrs1.err

>>I get:

>>tar: cannot open /netrs1/backup/netrs1.tar




>>>>Hi,

>>>>I'm trying to backup an AIX box using the following command:

>>>>find / -print | grep -v /netrs1/backup | tar cfL - >
>>>>/netrs1/backup/netrs1.tar 2> /netrs1/backup/netrs1.err

>>>I suspect you should do "tar cLf -", not "tar cfL -". Filename (in
>>>this case "-") should follow "f".

>>>mj

>>>>where netrs1 is the hostname, and /netrs1/backup is mounted on a remote

> box.

>>>>Anyway, what I'm trying to do is run tar on the / directory but exclude
>>>>directory /netrs1/backup. But the command I typed above doesn't work.
>>>>Could someone help me with the syntax please? (I'm using the AIX tar).

>>>>Thanks,

>>>>JS.

 
 
 

tar syntax question

Post by Alberto 'JCN-9000' Varesi » Thu, 14 Feb 2002 00:32:40


Hi folk,

AIX tar is not able to get file list from stdin/pipe.
you either need (A) GNU tar or (B) a two step command
A) find / -print | grep -v /netrs1/backup | \
   /usr/local/bin/tar -cvfT /netrs1/backup/netrs1.tar - \
   2> /netrs1/backup/netrs1.err
B) find / -print | grep -v /netrs1/backup > File.lst ;\
   tar cvfL /netrs1/backup/netrs1.tar File.lst 2> /netrs1/backup/netrs1.err

Pay attention to the list you build with find : you may get a double
sized backup due to the single file and parent directory archiving.

If list comes from find /a_dir you get :
/a_dir
/a_dir/a_file
/a_dir/b_file
/a_dir/c_file

tar will save the dir with its files and then the three files again :)

--
 Alberto 'JCN-9000' Varesio     AKA  BlueRider    AIX V4.3 System Support
 EADS-MDTV - Via Goito 51/A    Riding the world   Phone: +39-011-415-8111
 10195 Grugliasco (TO) ITALY   on a Honda CB500    Cell: +39-349-492-4769

--
 Anything that can go wrong will go wrong.             -- Murphy's Law #1

 
 
 

tar syntax question

Post by vervoo » Thu, 14 Feb 2002 01:36:52


So what we're really saying is, it would be a lot easier to do this with
the GNU tar because I could just do:

tar / --exclude /netrs1/backup -cvf /netrs1/backup/netrs1.tar 2>
/netrs1/backup/netrs1.err

with the GNU tar ?


> Hi folk,

> AIX tar is not able to get file list from stdin/pipe.
> you either need (A) GNU tar or (B) a two step command
> A) find / -print | grep -v /netrs1/backup | \
>    /usr/local/bin/tar -cvfT /netrs1/backup/netrs1.tar - \
>    2> /netrs1/backup/netrs1.err
> B) find / -print | grep -v /netrs1/backup > File.lst ;\
>    tar cvfL /netrs1/backup/netrs1.tar File.lst 2> /netrs1/backup/netrs1.err

> Pay attention to the list you build with find : you may get a double
> sized backup due to the single file and parent directory archiving.

> If list comes from find /a_dir you get :
> /a_dir
> /a_dir/a_file
> /a_dir/b_file
> /a_dir/c_file

> tar will save the dir with its files and then the three files again :)

 
 
 

tar syntax question

Post by Alberto 'JCN-9000' Varesi » Thu, 14 Feb 2002 01:54:44



> So what we're really saying is, it would be a lot easier to do this with
> the GNU tar because I could just do:

> tar / --exclude /netrs1/backup -cvf /netrs1/backup/netrs1.tar 2>
> /netrs1/backup/netrs1.err

> with the GNU tar ?

Should be
tar -cvf /netrs1/backup/netrs1.tar --exclude /netrs1/backup <dir_to_backup> \
 2> /netrs1/backup/netrs1.err

File list to archive _after_ command options, as usual.

--
 Alberto 'JCN-9000' Varesio     AKA  BlueRider    AIX V4.3 System Support
 EADS-MDTV - Via Goito 51/A    Riding the world   Phone: +39-011-415-8111
 10195 Grugliasco (TO) ITALY   on a Honda CB500    Cell: +39-349-492-4769

--
 Smith & Wesson: The original Point and Click interface!

 
 
 

tar syntax question

Post by Miljenko Jandr » Thu, 14 Feb 2002 01:52:58




>Now I see what you are trying to do.... Sorry, I misunderstood you the
>first time.

>Try one of these two:

>1) find / -print | grep -v /netrs1/backup | tar cL -
>-f /netrs1/backup/netrs1.tar 2> /netrs1/backup/netrs1.err

>(there is cL <space> - <space> -f <filename>)

Important correction: this will not work. L expects a single file
name, not a listing of files to back up. Even if L accepts "-" as an
argument, the command will fail.

However, 2) will be ok.

>or if that doesn't work try:

>2) tar -cf /netrs1/backup/netrs1.tar
>`find / -print | grep -v /netrs1/backup`  2> /netrs1/backup/netrs1.err

>(of course, this is one line. The "find" portion is in backquotes)

>I am not sure if "L" accepts "-" as an argument, so 1) might not work.
>However, 2) should be OK.

>Out of curiosity: you are trying to tar the whole system starting at
>root into a single tar file? Why?

>mj



>>If I try :

>>find / -print | grep -v /netrs1/backup | tar cLf
>>/netrs1/backup/netrs1.tar 2> /netrs1/backup/netrs1.err

>>I get:

>>tar: cannot open /netrs1/backup/netrs1.tar




>>>>Hi,

>>>>I'm trying to backup an AIX box using the following command:

>>>>find / -print | grep -v /netrs1/backup | tar cfL - >
>>>>/netrs1/backup/netrs1.tar 2> /netrs1/backup/netrs1.err

>>> I suspect you should do "tar cLf -", not "tar cfL -". Filename (in
>>> this case "-") should follow "f".

>>> mj

>>>>where netrs1 is the hostname, and /netrs1/backup is mounted on a remote box.

>>>>Anyway, what I'm trying to do is run tar on the / directory but exclude
>>>>directory /netrs1/backup. But the command I typed above doesn't work.
>>>>Could someone help me with the syntax please? (I'm using the AIX tar).

>>>>Thanks,

>>>>JS.

 
 
 

tar syntax question

Post by vervoo » Thu, 14 Feb 2002 02:20:27


Thanks for all your help everyone.


>>So what we're really saying is, it would be a lot easier to do this with
>>the GNU tar because I could just do:

>>tar / --exclude /netrs1/backup -cvf /netrs1/backup/netrs1.tar 2>
>>/netrs1/backup/netrs1.err

>>with the GNU tar ?

> Should be
> tar -cvf /netrs1/backup/netrs1.tar --exclude /netrs1/backup <dir_to_backup> \
>  2> /netrs1/backup/netrs1.err

> File list to archive _after_ command options, as usual.

 
 
 

tar syntax question

Post by vervoo » Thu, 14 Feb 2002 17:45:40


Maybe I spoke too soon. This is still going wrong:

/usr/local/gnu/bin/tar -cvf /tmp/mnt2/netrs1/netrs1.tar \
--exclude /tmp/mnt / 2> /tmp/mnt/netrs1/netrs1.err

When it runs, it still tars up files from /tmp/mnt into the archive.
I've tried all sorts of combinations to try and get the the GNU tar
--exclude and --exclude-from options to work but I've had no luck.

JS.


> Thanks for all your help everyone.



>>> So what we're really saying is, it would be a lot easier to do this with
>>> the GNU tar because I could just do:

>>> tar / --exclude /netrs1/backup -cvf /netrs1/backup/netrs1.tar 2>
>>> /netrs1/backup/netrs1.err

>>> with the GNU tar ?

>> Should be
>> tar -cvf /netrs1/backup/netrs1.tar --exclude /netrs1/backup
>> <dir_to_backup> \
>>  2> /netrs1/backup/netrs1.err

>> File list to archive _after_ command options, as usual.

 
 
 

tar syntax question

Post by Alberto 'JCN-9000' Varesi » Thu, 14 Feb 2002 19:22:01



> Maybe I spoke too soon. This is still going wrong:

> /usr/local/gnu/bin/tar -cvf /tmp/mnt2/netrs1/netrs1.tar \
> --exclude /tmp/mnt / 2> /tmp/mnt/netrs1/netrs1.err

> When it runs, it still tars up files from /tmp/mnt into the archive.
> I've tried all sorts of combinations to try and get the the GNU tar
> --exclude and --exclude-from options to work but I've had no luck.

Maybe it depends on tar version.
On AIX I have freeware.gnu.tar.rte 1.13.0.0 which is not working if
using --exclude=PATTERN  and PATTERN has a / (slash) inside.
On a Linux system running tar-1.13.11-2tr these same patterns work :(

Do we need to build tar from recent sources on AIX ... ?

--
 Alberto 'JCN-9000' Varesio     AKA  BlueRider    AIX V4.3 System Support
 EADS-MDTV - Via Goito 51/A    Riding the world   Phone: +39-011-415-8111
 10195 Grugliasco (TO) ITALY   on a Honda CB500    Cell: +39-349-492-4769

--
 Happy the bride who  . . . . . . . . . . . . . . gets all the presents

 
 
 

tar syntax question

Post by vervoo » Thu, 14 Feb 2002 20:29:38


tar 1.13 is the recent version. I downloaded it from
ftp://ftp.gnu.org/gnu and compiled it as follows:

LD_FLAGS="-bnso -bI:/lib/syscalls.exp" \
CC="cc" \
./configure --prefix=/usr/local/gnu --enable-exclude
make check

and that all went fine. --exclude stil doesn't work though. :(



>>Maybe I spoke too soon. This is still going wrong:

>>/usr/local/gnu/bin/tar -cvf /tmp/mnt2/netrs1/netrs1.tar \
>>--exclude /tmp/mnt / 2> /tmp/mnt/netrs1/netrs1.err

>>When it runs, it still tars up files from /tmp/mnt into the archive.
>>I've tried all sorts of combinations to try and get the the GNU tar
>>--exclude and --exclude-from options to work but I've had no luck.

> Maybe it depends on tar version.
> On AIX I have freeware.gnu.tar.rte 1.13.0.0 which is not working if
> using --exclude=PATTERN  and PATTERN has a / (slash) inside.
> On a Linux system running tar-1.13.11-2tr these same patterns work :(

> Do we need to build tar from recent sources on AIX ... ?

 
 
 

tar syntax question

Post by Alberto 'JCN-9000' Varesi » Thu, 14 Feb 2002 22:43:34



> tar 1.13 is the recent version. I downloaded it from
> ftp://ftp.gnu.org/gnu and compiled it as follows:

> LD_FLAGS="-bnso -bI:/lib/syscalls.exp" \
> CC="cc" \
> ./configure --prefix=/usr/local/gnu --enable-exclude
> make check

> and that all went fine. --exclude stil doesn't work though. :(

Plain 1.13 is not enough :

From NEWS file of a 1.13.19 tar SOURCE tree
===========================================
version 1.13.6 - Paul Eggert, 1999-08-11.

* An --exclude pattern containing / now excludes a file only if it matches an
  initial prefix of the file name; a pattern without / continues to
  exclude a file if it matches any file name component.

version 1.13.3 - Paul Eggert, 1999-07-16.

* A path name is excluded if any of its file name components matches an
  excluded pattern, even if the path name was specified on the command line.
  Also see 1.13.6 for later changes in this area.

also have a look at info docs regarding pattern handling ...
HTH

--
 Alberto 'JCN-9000' Varesio     AKA  BlueRider    AIX V4.3 System Support
 EADS-MDTV - Via Goito 51/A    Riding the world   Phone: +39-011-415-8111
 10195 Grugliasco (TO) ITALY   on a Honda CB500    Cell: +39-349-492-4769

--
 The best way to accelerate Windows is at -9.81 m/s2.

 
 
 

1. Tar Syntax Question

Hello,

    Here's my my problem:  I recently lost everything on my second hard
drive because of something that windoze did.  In order to fix
everything, I had to delete my partitions and format them. I tried to
recreate my partitions as they once were, but it caused all sorts of
problems with windows.  I was able to create a suitable Linux setup
minus the swap partition that I used to have.  (I don't think I needed
it anyway, in fact, whenever I checked, Linux was never using it.)
Luckily, I backed up everything to a tar.gz file on a Sparq cartridge.
The only thing is, my partitions now have different numbers i.e.
/dev/hdb5 is now /dev/hdb4 because my partition structure is different
than it was when I made the backup.  Obviously, this will cause a
problem when I restore the tar file, since files like
/etc/fstab,/etc/lilo.conf,  and /boot will want to point to the wrong
partitions.  (These are the only files that I can think of that would
cause a problem.  If you can think of others, please let me know.)  What
I'd like to know is, how can I exclude certain parts of the tar file
from being restored.  I figured out how to exclude files when making the
initial backup ex. --exclude=/proc, but I'm not sure how to do this when
restoring it.  Can anyone help me?  Thanks.....

PENN

2. Linux IPX

3. help on tar command and its syntax.

4. Dynamic SLIP

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

6. bootpd - bad addr len

7. Help with tar syntax please

8. security holes of news ?

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

10. Please help with tar syntax.

11. Understanding the syntax for invoking tar

12. tar syntax

13. TAR syntax