me,myself,english and programming..

Script to backup MySQL from server and dump to localhost

As a programmer, you will always find a way how to automate your task right ? do you ?

Well, this is my script to get the latest copy of mysql database into my local pc.

@Echo off
echo [%date% %time%] Starting backup...
mysqldump -u root -h 192.168.1.80 -pmyrootpwd mysqldb > mysqldb.sql
echo [%date% %time%] Starting dump....
mysql -u root -h localhost -pmyrootpwd mysqldb < mysqldb.sql
echo [%date% %time%] done.
pause

Save it as a batch file and just double click to run it. Your output will be something like below.

backup-restore-batch

 

Thats all. Hope it helps.

Post a Comment