How to backup al database in mysql

This script will create a backup for every database in $DEST folder.

#!/bin/sh

NOW=$(date +”%u”)
DEST=/backup/$HOSTNAME

echo “######################## Start Backup ”
mkdir -p $DEST

DBS=”$(mysql -Bse ‘show databases’)”

for db in $DBS
do
mysqldump $db > $DEST/$db-$NOW.sql
echo $db “Status : ” $?
done

Leave a Reply

Your email address will not be published. Required fields are marked *

Antispam Question * Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.