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 🙂 🙂

Leave a Reply