Automatic MySQL Backup using Batch File on Windows

Backup of your database are important. You can do the backup manually but automatic backup with regular time interval are good and time saving. In this post I am specifically talking about Mysql. Unfortunately there is no free solution for auto Backup. SoThere is a simple workaround available on windows platform to make MySQL backup automatically and freely. For this reason, you require a batch file and you have to write a batch script. And here are the steps for Mysql Database auto Backup:

1. Create a backup.bat file
2. Open the file in notepad and add this

echo off 
start "" "C:\wamp\bin\mysql\mysql5.6.12\bin\mysqldump.exe(your my sql dump address)" --user root --password=(provide your db password here) databaseNameHere --result-file="D:\database backup location SqlFileName.sql" --database databaseNameHere


Now let's break down the string we have mentioned in the above file:

C:\wamp\bin\mysql\mysql5.6.12\bin\mysqldump.exe(your mysqldump address)
This is the location of mysqldump file please locate your dump file path in paste its location with name and extension here. 

user root
Here you should provide your MySQL user name like in my case it is root

password=(provide here)
mysql password

databaseNameHere 
The database for which backup is required!

result-file="D:\where you want path with SqlFileName.sql"
This will be the location where you want to save the backup file. Please choose backup name wisely. If you want to place multiple backup files then you can use date in your file name like this
.%date:~10,4%-%date:~7,2%-%date:~4,2% Blockquote

3. The 3rd and final step: Use this batch file in your Windows Task Scheduler. Here is the detailed guide on how to add it to windows task scheduler.

So, within three steps you can make backup regularly.!

No comments:

Post a Comment