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,697 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
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…

628 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