[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: syntax error in backup script



thanks for your help guys.  I ran into a couple of good bash scripting
tutorials too, which also helped.

it seems to be working for the most part, but is a little buggy.

for example, i set up tar to only backup files which havent changed
since the last full backup.

this seems to work for some files, however tar seems to backup
everything in /var/www/ everytime whether its contents have changed or
not.

can anyone think of an explanation?


the revised (working) script is attached if anyone is interested.


jason
jason@pepas.com
jason.pepas.com


----- Original Message -----
From: "Morgan Terry" <mterry@acsbps.com>
To: <debian-user@lists.debian.org>
Sent: Tuesday, May 08, 2001 7:11 PM
Subject: Re: syntax error in backup script


> Jason Pepas wrote:
> >
> > i am brewing up a backup script, but i am running into an error
which
> > has me baffled.
> >
> > i try to run the script and get a syntax error which look something
like
> > this:
> >
> > syntax error near unexpected token 'elif'
> >
> > this is the line in question:
> >
> > elif [ ! -f "/backup/current/*fullbackup.tar.gz" ]
> >
> > here is the complete file (sorry, the formatting is mangled (no
> > indetions, etc)):
> >
> [...]
> > if [ `date +%A` = "Sunday" && ! -f "/backup/$directoryname" ] then
> >
> > # if it is sunday and you havent yet done a full backup, do so
> >
> > fullbackup
> >
> > elif [ ! -f "/backup/current/*fullbackup.tar.gz" ]
> [...]
>
> You need a semicolon after the closing bracket.
> From man sh:
>        if list; then list; [ elif list; then list; ] ... [ else
>        list;  ] fi
>               The if list is executed.  If  its  exit  status  is
>               zero,  the  then list is executed.  Otherwise, each
>               elif list is executed in turn, and if its exit sta­
>               tus  is  zero,  the corresponding then list is exe­
>               cuted and the command  completes.   Otherwise,  the
>               else list is executed, if present.  The exit status
>               is the exit status of the last command executed, or
>               zero if no condition tested true.
>
> This would change
>   if [ `date +%A` = "Sunday" && ! -f "/backup/$directoryname" ] then
> into
>   if [ `date +%A` = "Sunday" && ! -f "/backup/$directoryname" ]; then
>                                                                ^
>
> Do the same for the elif part.
>
> HTH
>
> > jason
> >
> > jason.pepas.com
>
> --
> Morgan Terry
> mterry@acsbps.com
>
> It is easier to move a problem around (for example, by moving
> the problem to a different part of the overall network
> architecture) than it is to solve it.  --RFC 1925
>
>
> --
> To UNSUBSCRIBE, email to debian-user-request@lists.debian.org
> with a subject of "unsubscribe". Trouble? Contact
listmaster@lists.debian.org
>

Attachment: backup.sh
Description: Binary data


Reply to: