MySql database backup shell script


#!/bin/sh


# Setting date to name the backupfile with todays date
date=`/bin/date "+%Y%m%d"`


# creating backup folder


/bin/mkdir -p /mysqlbkp/dbbackup_$date

DBS="$(mysql -Bse 'show databases')"


for db in $DBS


do


/usr/bin/mysqldump --routines $db > /mysqlbkp/dbbackup_$date/$db.sql


done


The backups will be generated in the location /mysqlbkp under the folder dbbackup_todays date.

Comments

Popular posts from this blog

Logical volume vmxxxx_img is used by another device - Error on LVM removal

Open VZ cheat Sheet

Cheat sheet for Hardware RAID health check - Megaraid, Adaptec, 3wareraid and HPraid.