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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
xampp tool 12 49
append to an ms access field 6 33
Excel - SQL export question 3 41
when to use sequences in mysql 4 27
I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
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…

770 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