MySqlBackup.NET
2.3.5.3
See the version list below for details.
dotnet add package MySqlBackup.NET --version 2.3.5.3
NuGet\Install-Package MySqlBackup.NET -Version 2.3.5.3
<PackageReference Include="MySqlBackup.NET" Version="2.3.5.3" />
paket add MySqlBackup.NET --version 2.3.5.3
#r "nuget: MySqlBackup.NET, 2.3.5.3"
// Install MySqlBackup.NET as a Cake Addin #addin nuget:?package=MySqlBackup.NET&version=2.3.5.3 // Install MySqlBackup.NET as a Cake Tool #tool nuget:?package=MySqlBackup.NET&version=2.3.5.3
About
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
More documentation is available at the Project Github website.
For MySql.Data.DLL PM> Install-Package MySqlBackup.NET https://www.nuget.org/packages/MySqlBackup.NET/
For dotConnector Devart.Express.MySql PM> Install-Package MySqlBackup.Net.DevartExpress https://www.nuget.org/packages/MySqlBackup.Net.DevartExpress/
For MySqlConnector (MIT) PM> Install-Package MySqlBackup.NET.MySqlConnector https://www.nuget.org/packages/MySqlBackup.NET.MysqlConnector/
Backup/Export a MySQL Database
string constring = "server=localhost;user=root;pwd=qwerty;database=test;convertzerodatetime=true;";
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;convertzerodatetime=true;";
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.
Option 1: MySql.Data (Connector/NET)
- MySQL dot net Connector/Net (MySql.Data.DLL)
- MySql.Data.DLL is developed by Oracle Corporation, licensed under GPL License (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)._
Option 2: Devart Express (dotConnect)
- Devart dotConnect for MySQL Express
- For license agreement, please read: https://www.devart.com/dotconnect/mysql/licensing-faq.html
- Devart.Data.DLL
- Devart.Data.MySql.DLL
Option 3: MySqlConnector (MIT)
- MySqlConnector: High Performance MySQL Library for .NET
- Project URL: https://github.com/mysql-net/MySqlConnector
- Licensed under MIT
- MySqlConnector.DLL
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=utf8mb4;convertzerodatetime=true;
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net452 is compatible. net46 was computed. net461 is compatible. net462 is compatible. net463 was computed. net47 is compatible. net471 is compatible. net472 is compatible. net48 is compatible. net481 was computed. |
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. |
-
.NETFramework 4.5.2
- MySql.Data (>= 8.0.26)
-
.NETFramework 4.6.1
- MySql.Data (>= 8.0.26)
-
.NETFramework 4.6.2
- MySql.Data (>= 8.0.26)
-
.NETFramework 4.7
- MySql.Data (>= 8.0.26)
-
.NETFramework 4.7.1
- MySql.Data (>= 8.0.26)
-
.NETFramework 4.7.2
- MySql.Data (>= 8.0.26)
-
.NETFramework 4.8
- MySql.Data (>= 8.0.26)
-
.NETStandard 2.0
- MySql.Data (>= 8.0.26)
NuGet packages (14)
Showing the top 5 NuGet packages that depend on MySqlBackup.NET:
Package | Downloads |
---|---|
Nascorp.Library
Library to methods utilities |
|
ThrowawayDb.MySql
Dead simple integration tests with Sql server throwaway databases. |
|
FrontLookCoreDbBackUpLibrary
This package adds an asp.net core database backup library! Supports MsSql And MySql. |
|
MyDapper
Dapper的操作帮助类 |
|
Panda.Tools
Package Description |
GitHub repositories (5)
Showing the top 5 popular GitHub repositories that depend on MySqlBackup.NET:
Repository | Stars |
---|---|
revenz/FileFlows
FileFlows is a file processing application that can execute actions against a file in a tree flow structure.
|
|
feiyit/FytSoaCms
NetCore2.2开发, Vs2017 数据Mysql
|
|
jaskie/PlayoutAutomation
Television broadcast automation system
|
|
Zaid-Ajaj/ThrowawayDb
Dead simple integration tests with SQL Server or Postgres throwaway databases that are created on the fly, used briefly then disposed of automagically.
|
|
logicpulse/logicPOS
Logicpulse's Open Source POS System
|
Version | Downloads | Last updated |
---|---|---|
2.3.8 | 75,778 | 3/7/2023 |
2.3.7 | 94,625 | 10/18/2022 |
2.3.6.1 | 136,991 | 10/20/2021 |
2.3.6 | 4,295 | 10/17/2021 |
2.3.5.3 | 4,145 | 9/24/2021 |
2.3.5.2 | 1,432 | 9/23/2021 |
2.3.5.1 | 1,499 | 9/22/2021 |
2.3.4.2 | 7,544 | 7/30/2021 |
2.3.4.1 | 6,209 | 7/12/2021 |
2.3.4 | 77,452 | 3/10/2021 |
2.3.3.1 | 41,862 | 7/16/2020 |
2.3.1 | 322,711 | 8/23/2019 |
2.3.0.1 | 9,551 | 7/26/2019 |
2.3.0 | 5,116 | 6/24/2019 |
2.2.1 | 15,411 | 4/7/2019 |
2.2.0 | 1,888 | 4/7/2019 |
2.1.0 | 14,925 | 12/1/2018 |
2.0.12.1 | 10,018 | 8/28/2018 |
2.0.12 | 25,103 | 3/26/2018 |
2.0.11.1 | 5,732 | 2/7/2018 |
2.0.11 | 2,387 | 2/7/2018 |
2.0.10.1 | 5,157 | 12/2/2017 |
2.0.10 | 4,124 | 12/1/2017 |
2.0.9.5 | 43,855 | 11/19/2016 |
2.0.9.4 | 8,386 | 3/20/2016 |
2.0.9.3 | 9,415 | 1/9/2016 |
2.0.9.2 | 6,506 | 8/8/2015 |
2.0.9.1 | 2,693 | 7/24/2015 |
2.0.9 | 2,595 | 7/19/2015 |
2.0.8 | 30,224 | 2/24/2015 |
2.0.7.1 | 17,320 | 1/26/2015 |
2.0.6 | 2,964 | 11/21/2014 |
2.0.5.1 | 2,604 | 10/20/2014 |
2.0.5 | 2,299 | 10/20/2014 |
2.0.4 | 3,924 | 5/12/2014 |
2.0.3 | 2,409 | 5/11/2014 |
2.0.2.1 | 3,153 | 4/10/2014 |
[New]
ExportInformation.EnableComment = true. (new option)
Added support for MySqlConnector (MIT)
ExportToFile(), if the directory is not existed. MySqlBackup will attempt to create it.
[Improve]
ImportInfo.ErrorLogFile = true. Now will include the query that causes the error.
ExportToFile = Auto created directory if not exists.
For non delimeter changed query execution, using MySqlCommand in stead of MySqlScript, slightly increase overall import speed.
Minor clean up.
Special thanks to Jean.R from
souchprod.com for the solution to support MySqlConnector.