how to take all mysql database backup using script?

Discussions related with hosting control panels used, which include cPanel, Plesk, Directadmin etc..

Moderator: Staff

Post Reply
Ashlin
Posts: 0
Joined: Fri Sep 16, 2016 10:10 am

how to take all mysql database backup using script?

Post by Ashlin »

Hi,

I need to upgrade mysql ,so I need to backup all my database .Is there any bash script for backup all my database for cpanel server?


Martin
Posts: 36
Joined: Fri Sep 16, 2016 10:34 am

Re: how to take all mysql database backup using script?

Post by Martin »

Use the below script to take backup of all databases on the server.

mkdir /home/mysqldump
cd /home/mysqldump

root@server [~]# vi db-backup.sh

#!/bin/sh
for i in `mysql -e'show databases' | grep -v 'Database\|performance_schema\|information_schema'` ;
do
mysqldump $i > /home/mysqldump/$i.sql
done

=============================
Martin
Linux Support Engineer.
Nixtree Solutions
Managed Full Server Backups
https://www.nixtree.com/managed-backups.php
Follow us on : https://twitter.com/nixtree


If you are looking for assistance in server management, please get in touch with our support.
Post Reply