Dump and Restore Progress

Dump and Restore Progress

Postby 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.
BrianM
 
Posts: 2
Joined: Mon 12 Dec 2011 16:19

Postby 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
Pinturiccio
Devart Team
 
Posts: 2026
Joined: Wed 02 Nov 2011 09:44

Postby BrianM » Thu 15 Dec 2011 16:07

Thanks Pinturiccio, worked perfect. I was trying to use MySQLDump.Restore with no luck.
BrianM
 
Posts: 2
Joined: Mon 12 Dec 2011 16:19


Return to dotConnect for MySQL