Before you make any changes to MySQL service or upgrade MySQL version, it is recommended to take full backup of MySQL databases. If any thing goes wrong then we can restore all databases from MySQL backup.
Follow below steps to create backup of MySQL databases :
1. Login to ssh shell with root user
2. Create a folder for backup files
# mkdir /backup/mysql_backup_29-Mar-2019
3. Now we will collect a list of all databases name into /root/dhlist.txt Text file
# plesk db -e “show databases” | grep -v -E “^Database|information_schema|performance_schema|phpmyadmin” > /root/dblist.txt
4. Now we will take backup of all databases with below command :
# cat /root/dblist.txt | while read i; do plesk db dump “$i” > /backup/mysql_backup_29-Mar-2019/”$i”.sql; done
Now you have backup of all databases into “/backup/mysql_backup_29-Mar-2019/” folder. You can copy it at remote location or download it on your computer.
If you want to restore all databases which are into “/backup/mysql_backup_29-Mar-2019/” folder then please enter below command :
# for i in `cat /root/dblist.txt`; do MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql -u admin < /backup/mysql_backup_29-Mar-2019/”$i”.sql; done
Please feel free to contact us at [email protected] if you require any assistance.