Script questions...

Script questions...

Post by Barry Margoli » Tue, 24 Feb 2004 11:50:50





> Hi,

> Thanks in advance for any and all help on this.

> I have a script as follows:

> #!/bin/sh
> BACKUPDIR="/backup/"
> BCKP_LIST="/etc /var /home/*/www/*.*/logs/"
> BCKP_FILE="`date -I`.backup.tar"
> cd $BACKUPDIR
> tar -cpf $BCKP_FILE $BCKP_LIST -X uh_list
> gzip `date -I`.backup.tar
> chown root.root $FILE_NAME
> chmod 0400 $FILE_NAME

> (uh_list is a list of files I want to exclude from the /var/ directory)

> If I run the script, it doesn't work.  It creates the tar file, but
> there's nothing in it.  Running the script one line at a time from the
> command line tells me that tar can't open /etc/, as it is a directory.

Did you cut and paste the file into the message, or retype it?  My guess
is that you have a typo in the variable name BCKP_FILE on one of the
lines that mentions it, so you're ending up with:

tar -cpf $BCKP_LIST ...

Try running the script with "sh -x" to see the expansion of each line as
it executes.

--

Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***

 
 
 

Script questions...

Post by Stuart Fulle » Tue, 24 Feb 2004 11:53:42



> Hi,

> Thanks in advance for any and all help on this.

> I have a script as follows:

> #!/bin/sh
> BACKUPDIR="/backup/"
> BCKP_LIST="/etc /var /home/*/www/*.*/logs/"
> BCKP_FILE="`date -I`.backup.tar"
> cd $BACKUPDIR
> tar -cpf $BCKP_FILE $BCKP_LIST -X uh_list
> gzip `date -I`.backup.tar
> chown root.root $FILE_NAME
> chmod 0400 $FILE_NAME

> (uh_list is a list of files I want to exclude from the /var/ directory)

> If I run the script, it doesn't work.  It creates the tar file, but
> there's nothing in it.  Running the script one line at a time from the
> command line tells me that tar can't open /etc/, as it is a directory.

> If I do the following:

> tar -cpf test.tar /etc /var /home/*/www/*.*/logs

> It works perfectly.

The script also has a "-X uh_list", but you don't show that you tested that
manually.  If you add that switch and argument, what happens?
--

        Stu

 
 
 

Script questions...

Post by Bill Marcu » Tue, 24 Feb 2004 15:06:30


On Sun, 22 Feb 2004 22:00:03 -0500, Tigerhost

> Hi,

> I copied and pasted.  I used "sh -x", and it properly expands the list of
> files, but it only seems to be tarring the directories themselves, and not
> the actual contents of the directories.  Very weird...

Do you run the script as root, or do you have read permission to all
the directories?  Try "tar -cpvf".

--
Incrsease your earoning poswer and gaerner profwessional resspect.
Get the Un1iversity Dewgree you have already earned.
 [from the University of Spam!]

 
 
 

Script questions...

Post by Willia » Wed, 25 Feb 2004 01:02:58



Quote:> Hi,

> Thanks in advance for any and all help on this.

> I have a script as follows:

> #!/bin/sh
> BACKUPDIR="/backup/"
> BCKP_LIST="/etc /var /home/*/www/*.*/logs/"
> BCKP_FILE="`date -I`.backup.tar"
> cd $BACKUPDIR
> tar -cpf $BCKP_FILE $BCKP_LIST -X uh_list
> gzip `date -I`.backup.tar
> chown root.root $FILE_NAME
> chmod 0400 $FILE_NAME

> (uh_list is a list of files I want to exclude from the /var/ directory)

> If I run the script, it doesn't work.  It creates the tar file, but
> there's nothing in it.  Running the script one line at a time from the
> command line tells me that tar can't open /etc/, as it is a directory.

You might try replacing
    > tar -cpf $BCKP_FILE $BCKP_LIST -X uh_list
with
    eval tar -cpf $BCKP_FILE $BCKP_LIST -X uh_list

-Wm