Free for PREMIUM members
[Webinar] Streamline your web hosting managementRegister Today
# Shell script to backup MySql database
# To backup Mysql databases file to /backup dir and later pick up by your
MyUSER="SET-MYSQL-USER-NAME" # USERNAME
MyPASS="SET-PASSWORD" # PASSWORD
MyHOST="localhost" # Hostname
# Linux bin paths, change this if it can't be autodetected via which command
# Backup Dest directory, change this if you have someother location
# Main directory where backup will be stored
# Get hostname
# Get data in dd-mm-yyyy format
# File to store current backup file
# Store list of databases
# DO NOT BACKUP these databases
[ ! -d $MBD ] && mkdir -p $MBD || :
# Only root can access it!
$CHOWN 0.0 -R $DEST
$CHMOD 0600 $DEST
# Get all database list first
DBS="$($MYSQL -u $MyUSER -h $MyHOST -p$MyPASS -Bse 'show databases')"
for db in $DBS
if [ "$IGGY" != "" ];
for i in $IGGY
[ "$db" == "$i" ] && skipdb=1 || :
if [ "$skipdb" == "-1" ] ; then
# do all inone job in pipe,
# connect to mysql using mysqldump for select mysql database
# and pipe it out to gz file in backup dir :)
$MYSQLDUMP -u $MyUSER -h $MyHOST -p$MyPASS $db | $GZIP -9 > $FILE
Open in new window
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.
Premium members get this course for $31.25.
Premium members get this course for $159.20.
Premium members get this course for $174.99.
Premium members get this course for $95.20.
Premium members get this course for $25.00.
Premium members get this course for $151.20.
Premium members get this course for $108.00.
Premium members get this course for $87.50.