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,678 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
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…

910 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

23 Experts available now in Live!

Get 1:1 Help Now