Page 1 of 1

Dump and Restore Progress

Posted: Mon 12 Dec 2011 16:22
by BrianM
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.

Posted: Thu 15 Dec 2011 11:09
by Pinturiccio
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

Posted: Thu 15 Dec 2011 16:07
by BrianM
Thanks Pinturiccio, worked perfect. I was trying to use MySQLDump.Restore with no luck.