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

Re: Help with a bash script please



Hi Adrian,

On 01/14/2011 10:33 AM, Adrian Levi wrote:
> I have the following bash script and it fails at line 14 and 15
> (7zparameters= and 7zfilename=) I have tried everything i can think of
> to get it to work, the answer has to be simple but i can't figure it.
>
> This is going to be my new backup script, based on an earlier version
> that is very similar in functionality except I wasn't using tar, in
> that version.
>
> #!/bin/sh
> # Variables:
> # Determine backup level
> incrementalfile="/srv/tar_incremental_file"
>
> if [ -f $incrementalfile ]
> then
> backuplevel=`date +%w`
> else
> backuplevel="0"
> rm $incrementalfile>  /dev/null 2>&1
> fi
>
> 7zparameters='a -si -mhe=on -ppassword -t7z -m0=lzma -mx=9 -mfb=64
> -md=32m -ms=on -l'

Variable names can't start with a digit (as in 7zfilename=...).

> 7zfilename='Daily backup - `date +%a" "%h" "%H%M"
> "%d-%m-%Y`.$backuplevel.tar.7z'

The single quotes will prevent the date command from happening. So you 
need to use double quotes.

> ...

Regards,

Jochem



Reply to: