MySQL backup script



#! /bin/bash
### MySQL Server Login Info ###
MUSER="root"
MPASS="roott123"
MHOST="localhost"
MPORT="3306"
DBNAME="radius"
MYSQL="$(which mysql)"
MYSQLDUMP="$(which mysqldump)"


### File Info ###
# Save backup in temp directory before upload to server
TEMPDIR="/root/backup_radius" #Exp: ./bkp_temp

# Name of bkp file (before the date)
FILENAME="Radius_Backup_" #Exp: my_prj_daily_bkp_
NOW=$(date +%F)


#Create and clean temp directory
[ ! -d "$TEMPDIR" ] && mkdir -p "$TEMPDIR"
rm -f "$TEMPDIR"/*.*

# Create bkp
TFILENAME="$FILENAME""$NOW".sql
FILE=$TEMPDIR/$TFILENAME
$MYSQLDUMP -u $MUSER -h $MHOST -P $MPORT  -p$MPASS $DBNAME > $FILE
~

0 $type={blogger}: