Dump and Restore Progress

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply
BrianM
Posts: 2
Joined: Mon 12 Dec 2011 16:19

Dump and Restore Progress

Post by BrianM » Mon 12 Dec 2011 16:22

I am able to to a Backup and monitor the progress, but can't seem to get the progress for the restore. Any advice here?

Thanks in advance.

Pinturiccio
Devart Team
Posts: 2192
Joined: Wed 02 Nov 2011 09:44

Post by Pinturiccio » Thu 15 Dec 2011 11:09

There is the Progress event in MySqlDump. Almost all properties of MySqlDumpProgressEventArgs work with backup. But you can receive such information for Restoring by using MySqlScript. Our MySqlDump.Restore() uses MySqlScript for restoring. It takes MySqlDump.DumpText and Execute a MySqlScript. All this is performed inside the Restore function.
You can use MySqlScript and get access to the MySqlScript.Progress event.

Create MySqlDump:

Code: Select all

            MySqlDump dump = new MySqlDump(conn);
            conn.Open();
Backuping into D:\mydump.txt file

Code: Select all

            dump.Backup("D:\mydump.txt");
Restoring from D:\mydump.txt file via MySqlScript

Code: Select all

            FileInfo file = new FileInfo("D:\mydump.txt"); 
            MySqlScript script = new MySqlScript();
            script.Connection = conn;
            script.ScriptText = file.OpenText().ReadToEnd();
            script.Progress+= new Devart.Common.ScriptProgressEventHandler(onProgress);

            IDataReader reader;
            while (script.ExecuteNext(out reader))
            {
                reader.Close();
            }
Event handler

Code: Select all

            static void onProgress(object sender, Devart.Common.ScriptProgressEventArgs e)
            {
            	//percentage of the operation completion
            	Console.WriteLine((100*e.Offset)/((MySqlScript)sender).ScriptText.Length);
            	//Console.WriteLine(e.Text); //Executed script text
            }
For more information about the MySqlScript Progress event please refer to http://www.devart.com/dotconnect/mysql/ ... ss_EV.html

BrianM
Posts: 2
Joined: Mon 12 Dec 2011 16:19

Post by BrianM » Thu 15 Dec 2011 16:07

Thanks Pinturiccio, worked perfect. I was trying to use MySQLDump.Restore with no luck.

Post Reply