MySqlBackup.NET.MySqlConnector 2.3.8

dotnet add package MySqlBackup.NET.MySqlConnector --version 2.3.8                
NuGet\Install-Package MySqlBackup.NET.MySqlConnector -Version 2.3.8                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MySqlBackup.NET.MySqlConnector" Version="2.3.8" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MySqlBackup.NET.MySqlConnector --version 2.3.8                
#r "nuget: MySqlBackup.NET.MySqlConnector, 2.3.8"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install MySqlBackup.NET.MySqlConnector as a Cake Addin
#addin nuget:?package=MySqlBackup.NET.MySqlConnector&version=2.3.8

// Install MySqlBackup.NET.MySqlConnector as a Cake Tool
#tool nuget:?package=MySqlBackup.NET.MySqlConnector&version=2.3.8                

MySqlBackup.Net

A tool to backup and restore MySQL database in C#/VB.NET/ASP.NET.

Runs on MySql.Data.DLL, MySqlConnector.DLL and Devart.Express.MySql.DLL

How to Add This Library into Your Project

Read this wiki: How to Add This Library into Your Project

Backup ALL Databases in 1 Click

Export all the databases one by one to separate SQL dump files. This a sub-project expansion using MySqlBackup.NET. Read more: MySqlBackup_All_DB

Download

https://github.com/MySqlBackupNET/MySqlBackup.Net/releases

Install via NuGet:

PM> Install-Package MySqlBackup.NET
https://www.nuget.org/packages/MySqlBackup.NET/

PM> Install-Package MySqlBackup.Net.DevartExpress<br /> https://www.nuget.org/packages/MySqlBackup.Net.DevartExpress/

PM> Install-Package MySqlBackup.NET.MySqlConnector<br /> https://www.nuget.org/packages/MySqlBackup.NET.MysqlConnector/

Backup/Export a MySQL Database

string constring = "server=localhost;user=root;pwd=qwerty;database=test;";
string file = "C:\\backup.sql";
using (MySqlConnection conn = new MySqlConnection(constring))
{
    using (MySqlCommand cmd = new MySqlCommand())
    {
        using (MySqlBackup mb = new MySqlBackup(cmd))
        {
            cmd.Connection = conn;
            conn.Open();
            mb.ExportToFile(file);
            conn.Close();
        }
    }
}

Import/Restore a MySQL Database

string constring = "server=localhost;user=root;pwd=qwerty;database=test;";
string file = "C:\\backup.sql";
using (MySqlConnection conn = new MySqlConnection(constring))
{
    using (MySqlCommand cmd = new MySqlCommand())
    {
        using (MySqlBackup mb = new MySqlBackup(cmd))
        {
            cmd.Connection = conn;
            conn.Open();
            mb.ImportFromFile(file);
            conn.Close();
        }
    }
}

Introduction

MySqlBackup.NET is a tool (DLL) that can backup/restore MySQL database in .NET Programming Language. It is an alternative to MySqlDump.

This tool is developed in C# but able to be used in any .NET Language (i.e. VB.NET, F#, etc.).

Another benefit of making this tool is, we don't have to rely on two small programs - MySqlDump.exe and MySql.exe to perform the backup and restore task. We will have better control on the output result in .NET way.

The most common way to backup a MySQL Database is by using MySqlDump and MySQL Workbench.

MySQL Workbench is good for developers, but when comes to the client or end-user, the recommended way is to get every parameter preset and all they need to know is press the big button "Backup" and everything is done. Using MySQL Workbench as a backup tool is not a suitable solution for the client or end-user.

On the other hand, MySqlDump.exe cannot be executed directly from the Web Server. As some providers forbid that, MySqlBackup will be helpful in building a web-based (ASP.NET) backup tool.

Features

  • Backup and Restore of MySQL Database
  • Can be used in any .NET Languages.
  • Export/Import to/from MemoryStream
  • Conditional Rows Export (Filter Tables or Rows)
  • Progress Report is Available for Both Export and Import Task.
  • Able to export rows into different modes. (Insert, Insert Ignore, Replace, On Duplicate Key Update, Update)
  • Can be used directly in ASP.NET or web services.

Prerequisite and Dependencies for Development, Compile and Production Usage

MySqlBackup.NET relies on the following component to work.

<b>Option 1: MySql.Data (Connector/NET)</b>

<b>Option 2: Devart Express (dotConnect)</b>

<b>Option 3: MySqlConnector (MIT)</b>

Reminder

Reminder 1

MySqlBackup.NET (or MySqlBackup.DLL) stands on top of MySql.Data.DLL which also stands on top of .NET Framework, which uses UTF8 encoding by default. If your database involves any UTF8 or Unicode Characters. You must use a MySQL database with default character of UTF8 while handling Unicode Characters, such as

  • Western European specific languages, the character of 'À', 'ë', 'õ', 'Ñ'.
  • Russian, Hebrew, India, Arabic, Chinese, Korean, Japanese characters, etc.

You are recommended to apply the connection string option of charset=utf8. Example:

server=localhost;user=root;pwd=mypwd;charset=utf8;

or

server=localhost;user=root;pwd=mypwd;charset=utf8mb4;

Reminder 2

(For MySql.Data connector only) DateTime conversion between MySQL and .NET Framework. In MySQL, there are various of DateTime format, such as null value or Date only data. But, in .NET Framework, there is no null value (or Date only) for DateTime. This error is not caused by MySqlBackup.DLL. MySql.Data.DLL (developed by Oracle) has decided to throw an exception of Data Conversion Error. Therefore, you are strongly recommended to apply the connection string option of convertzerodatetime=true. Example:

server=localhost;user=root;pwd=mypwd;charset=utf8;convertzerodatetime=true;

Performance Benchmark (MySqlDump vs MySqlBackup.NET)

Full Report - Wiki Page: Performance Benchmark (MySqlDump vs MySqlBackup.NET))

Summary Benchmark Report:

Database Size: 3.5GB (15 million rows)

Process     Tools              Time
-------     ---------          ------
Backup 1    MySqlDump         2m 36s
Backup 2    MySqlDump         2m 33s
Backup 3    MySqlDump         2m 35s

File size: 
4.66 GB (5,008,487,275 bytes)

Backup 4    MySqlBackup.NET   7m 48s
Backup 5    MySqlBackup.NET   7m 46s
Backup 6    MySqlBackup.NET   7m 50s

File size:
4.59 GB (4,931,743,894 bytes)

Restore 1   MySql.exe         8m 42s
Restore 2   MySql.exe         8m 23s
Restore 3   MySql.exe         8m 57s

Restore 4   MySqlBackup.NET   9m 44s
Restore 5   MySqlBackup.NET   9m 39s
Restore 6   MySqlBackup.NET   9m 39s

License

MySqlBackup.Net is licensed under the The Unlicense.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 is compatible. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 is compatible.  net472 was computed.  net48 is compatible.  net481 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on MySqlBackup.NET.MySqlConnector:

Package Downloads
Panda.Tools

Package Description

CL.Sinks.MySql.Backup.MySqlConnector

MySql helper library that uses fluent interface to backup/restore MySql Database to/from different storage locations such as Local, Azure Blob, S3, DropBox, OneDrive, DO spaces, etc. storage. It's using MySqlBackup.NET as core library to perform work of backup/restore

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on MySqlBackup.NET.MySqlConnector:

Repository Stars
ShokoAnime/ShokoServer
Repository for Shoko Server.
Version Downloads Last updated
2.3.8 231,679 3/7/2023
2.3.7 9,910 10/18/2022
2.3.6 16,760 10/17/2021
2.3.5.1 997 10/6/2021
2.3.5 712 9/23/2021
2.3.4.2 899 9/21/2021

Fix a bug where MySqlDateTime is not handled.