tags:

views:

1701

answers:

4

How do you create a database backup of a mysql database in VB.Net?

+1  A: 

you could invoke mysqldump, but you may need to be running your VB.NET on the Mysql server.

Osama ALASSIRY
A: 

You can read each table's data and write it to a new database.

Bob King
A: 

I would write a stored proc, since MySQL 5 has support for them, that handles all the data "heavy" work. Then just create scheduled task that calls the procedure every "night". For this latter component, I highly recommend Powershell....its awesome.

websch01ar
+1  A: 

I found the easiest way was to use the mysqldump.exe which is a standalone application.

mysqldump --host=[HOSTNAME] --user=[USER] --password=[PASSWORD] -R [DATABASE NAME] > [PATH TO BACKUP FILE]

We had issues with backups not saving db functions but the -R switch sorted it so id recommend using it if you use stored procedures or functions in your DB.

to restore the created file use the mysql command instead.

mysql --host=[HOSTNAME] --user=[USER] --password=[PASSWORD] [DATABASE NAME] < [PATH TO BACKUP FILE]
Kaius