Dump All MySQL Databases Starting with Prefix

 

Hello,

 

The following shell/bash script will help you in taking backup of databases starting with prefix.

 

#!/bin/bash
#Script for mysql database backup

cd /var/lib/mysql
#Path to mysql folder I am using default path here
for DBs in $(ls -d */ |grep dbprefix_ | tr -d /)
do

cd /mysqlbackup

`mysqldump -u root -p'password' $DBs > $DBs.sql`


done

Leave a Reply

Protected by WP Anti Spam