Hi,
I have been using a bash script to backup a MySQL database for at least a year now, however, I have recently upgraded my Debian distribution to Squeeze and my script will no longer run. It complains about a problem with a function.
Any ideas what is going wrong here?
This is the original script:
Code:
#!/bin/sh -x
#
#Simple script to backup the expenses database
#to a bzip2 compressed file.
#
#use bzip2 -d to decompress.
#
#00 22 * * * /root/scripts/expenses_backup.sh
#
function report () {
echo "$(date '+%Y-%m-%d %H:%M:%S') $1" >> $LOG
}
BDIR=/var/local/backup/expenses
DOW=`date +%a`
LOG=/root/scripts/logs/expenses_backup.log
export PATH="$PATH:/usr/bin:/bin"
report "Starting backup of expenses database"
mysqldump -uexpenses -pexpenses expenses | bzip2 > $BDIR/$DOW.sql.bz2
report "Completed backup of expenses database"
When executed it complains about:
./expenses_backup.sh
./expenses_backup.sh: 11: Syntax error: "(" unexpected
To test this I created a smaller simpler script, but I can only get this to run when I remove the word function. I like to have to word function in there so others can understand the scripts I write.
Code:
#!/bin/sh
report () {
echo report
}
report test
Many thanks for helping me understand where I am going wrong here. I have read man pages and been googling to no avail
