Tuesday 14 February 2012

Script to Make a backup of the current database and restore DB from the available backup of all the database owned by a particular user in cPanel

You can make use of the following script to generate a backup of all the databases and also restoring the DB from the available backup in cPanel owned by a particular user.

=============
#!/bin/bash
cd /var/lib/mysql
ls -al | grep username | awk {'print$9'} > dblist
for i in `cat dblist`
do
mysqldump $i > $i.sql;
mv $i.sql /home/username
done
cp /backup/cpbackup/monthly/username/mysql/yogabook_*.sql /var/lib/mysql
for i in `cat dblist`
do
mysql $i < $i.sql;
done

=============

Have a Great Day :) :)

No comments: