shell script to backup mysql databases


The following shell script will backup all the individual databases present in your server in .sql format and store it under /mysqlbackup folder. Make sure you have mysql databases in /var/lib/mysql and a folder with name /mysqlbackup. Set a cron to run this script once a day.

#Script for mysql database backup
cd /var/lib/mysql
for DBs in $(ls -d */ |tr -d /)

cd /mysqlbackup

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


Thank you for viewing

Leave a Reply

Protected by WP Anti Spam