Jump to content

Backup MySQL databases on windows (.bat file)


dotnetic
 Share

Recommended Posts

Hey guys I wanted to share this little snippet with you, which can be run as a .bat file, and backups all of your databases into a separate file:

K:\laragon\bin\mysql\mysql-5.7.19-winx64\bin\mysql.exe -uroot -s -N -e "SHOW DATABASES" | for /F "usebackq" %%D in (`findstr /V "information_schema performance_schema"`) do K:\laragon\bin\mysql\mysql-5.7.19-winx64\bin\mysqldump.exe %%D -uroot > P:\htdocs\database-backups\%%D.sql

of course you have to change the paths to your mysql/mysqldump.exe files and the destination directory, and the username, if you have to provide another than root.

This task can be executed daily via task scheduling in Windows.

  • Like 3
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...