Solved

How to create a MSDOS Batch Script to backup all mysql database into separate file for restoration

Posted on 2009-04-13
5
1,675 Views
Last Modified: 2012-05-06
Hi,

I would like to request an assistant.

My mysql database mysqldump.exe file and bin folder is located at C:\Program Files\SWsoft\Plesk\Databases\MySQL\bin .

May i know how to create a MSDOS batch script to dump/backup hundreds of my database into a separate .sql backup file for restoration purposes ?

FYI, my database is located in C:\Program Files\SWsoft\Plesk\Databases\MySQL\data folder .

Appreciates if anybody can draw a script to backup all the database and also to restore the database on the other server.

Thank you.
0
Comment
Question by:smksa
  • 2
5 Comments
 
LVL 15

Expert Comment

by:oobayly
ID: 24132020
You could use the vb script. It needs a file called databases.txt in the same directory which contain each database name on a new line.
It loops through each db, calling mysqldump for each one, and outputing to a names sql dump file
option explicit
 

dim shell, fso, txtDB, db, resp

set fso = CreateObject("Scripting.FileSystemObject")

set shell = CreateObject("WScript.Shell")
 

' Open the Database file

set txtDB = fso.OpenTextFile("databases.txt")
 

' Read each line

while(not txtDB.AtEndOfStream)

  db = txtDB.ReadLine()

  if (trim(db) <> "") then

     resp = shell.run("mysqldump.exe -h <host> -u <user> -pPassword " + db + " > " + db + ".sql")

  end if

wend
 

txtDB.close()

Open in new window

0
 
LVL 8

Expert Comment

by:vinurajr
ID: 24132514
0
 
LVL 8

Accepted Solution

by:
vinurajr earned 500 total points
ID: 24132526
0
 
LVL 2

Author Comment

by:smksa
ID: 24134422
Hi,

May i know how to restore using a script to restore all the database that has been backup ?

Appreciates if you can add some notes or scripts.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Creating and Managing Databases with phpMyAdmin in cPanel.
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now