Howdy all, I have a scritp that does a sqldump. But for some goofy reason, a certain part of it behaves uber strange.
It does a daily dump of my sql, according to parameters I enter in hardcode.
The script is:
#!/bin/bash
APP_NAME="app_com_site"
wikiname="wiki_com_site"
BACKUP_DIR="/home/app/backup/DAILY"
DB_NAME="app_com_db"
DB_USER="app_com_admi"
DB_PASS="notgonnatellyou"
# Number of Backup files to save
FILES_TO_KEEP=2
##################
# END OF OPTIONS #
##################
timestamp=`date +%Y-%m-%d`
dbdump="$BACKUP_DIR/$APP_NAME-$timestamp.sql.gz"
filedump="$BACKUP_DIR/$APP_NAME-$timestamp.files.tgz"
#Create a MySQL dump of the database
echo "creating database dump:" $dbdump
mysqldump --database $DB_NAME -u $DB_USER -p$DB_PASS --add-drop-table -B | gzip > test.gz
#mysqldump --database $DB_NAME -u $DB_USER -p$DB_PASS --add-drop-table -B | gzip > "$dbdump"
The thing is that the commented line is NOT creating the file, but the uncommented one IS working. I do want this to be dynamically.
I couldn't find any errors. can anyone have a clue please?
Adding the brackets to my source code, didn't change the result.
I started to think that it's permission issue.
The target folder is 755, and owned by the same user that is running the script (other user that runs the cron job is root - at night run). so I don't think it's permissions.
Why is it that if I put a direct file name it works, but using a parameter it doesn't?
---------- Post updated at 03:09 PM ---------- Previous update was at 02:42 PM ----------
I had another try, to see if I can make this work in a different way:
These two lines are working, the name of the output sql file and gz file are hardcoded.