Hi,
I'm trying to write a script which will take mysqldump from a server and put it in a directory with today's date. Here's the script i've written so far:
Code:
#!/bin/sh
BACKUP=/data/backup/sql2/new_backup/daily
cd $BACKUP
mkdir `date '+%m%d%y'`
NOW=$(date +"%d-%m-%Y")
MUSER="root"
MPASS="mypass"
MHOST="sql2"
MYSQL="$(which mysql)"
MYSQLDUMP="$(which mysqldump)"
GZIP="$(which gzip)"
DBS="$($MYSQL -u $MUSER -h $MHOST -p$MPASS -Bse 'show databases')"
for db in $DBS
do
FILE=$BACKUP/mysql-$db.$NOW-$(date +"%T").sql.gz
$MYSQLDUMP -u $MUSER -h $MHOST -p$MPASS --lock-all-tables $db | $GZIP -9 > $FILE
done
I want to put the mysql dump in the today's directory. How can i declare this?
Thanks.