MySQL backup of all databases on Windows Server

Contains tips for configurators working with Aware IM
Post Reply
Posts: 174
Joined: Wed Nov 06, 2019 9:49 pm
Location: Sweden

MySQL backup of all databases on Windows Server

Post by joben »

This script will dump each database to its own .sql file:

mysql.exe -uuser -ppassword -s -N -e "SHOW DATABASES" | for /F "usebackq" %%D in (`findstr /V "information_schema performance_schema"`) do mysqldump %%D -uuser -ppassword > C:\MysqlBackup\%%D.sql

Save it as a .bat file.
Schedule it via Task Scheduler.
Don't know where I originally found it, but it works great.
This script loops through all databases. Any future databases added to MySQL will automatically become protected.

Prerequisite! You need to add this inside the system environment variable called Path:

Code: Select all

C:\Program Files\MySQL\MySQL Server 8.0\bin
(switch 8.0 to the version you are running)
addpath-min.png (92.37 KiB) Viewed 6072 times
Regards, Joakim

Post Reply