MySqlBackup.NET 2.6.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package MySqlBackup.NET --version 2.6.0
                    
NuGet\Install-Package MySqlBackup.NET -Version 2.6.0
                    
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" Version="2.6.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MySqlBackup.NET" Version="2.6.0" />
                    
Directory.Packages.props
<PackageReference Include="MySqlBackup.NET" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MySqlBackup.NET --version 2.6.0
                    
#r "nuget: MySqlBackup.NET, 2.6.0"
                    
#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.
#addin nuget:?package=MySqlBackup.NET&version=2.6.0
                    
Install as a Cake Addin
#tool nuget:?package=MySqlBackup.NET&version=2.6.0
                    
Install as a Cake Tool

MySqlBackup.NET

A versatile tool for backing up and restoring MySQL databases in C#, VB.NET, and ASP.NET.

Latest Release: v2.6 (July 04, 2025)
Change Log


Overview

MySqlBackup.NET is a .NET library (DLL) designed to backup and restore MySQL databases. Compatible with multiple MySQL connectors—MySql.Data.DLL, MySqlConnector.DLL, and Devart.Express.MySql.DLL—it offers a programmatic alternative to tools like MySqlDump, providing greater control and flexibility in .NET environments.

Developed in C#, this library supports any .NET language (e.g., VB.NET, F#) and excels in scenarios where MySqlDump.exe or MySQL Workbench are impractical, such as web-based applications (ASP.NET) or end-user tools with simplified interfaces.


Key Features

  • Backup and restore MySQL databases programmatically.
  • Supports all .NET languages.
  • Export/import via files or MemoryStream.
  • Conditional row exports (filter tables/rows).
  • Progress reporting for export and import tasks.
  • Flexible row export modes: INSERT, INSERT IGNORE, REPLACE, ON DUPLICATE KEY UPDATE, UPDATE.
  • Ideal for ASP.NET and web service integration.

Getting Started

Installation

Download

Grab the latest release from: GitHub Releases

NuGet Packages

Install via NuGet Package Manager:

Add to Your Project

See the detailed guide:
How to Add This Library into Your Project


Basic Usage

Backup a Database
string constr = "server=localhost;user=root;pwd=1234;database=test1;convertzerodatetime=true;";
string filePath = @"C:\backup.sql";

using (var conn = new MySqlConnection(constr))
using (var cmd = conn.CreateCommand())
using (var mb = new MySqlBackup(cmd))
{
    conn.Open();
    mb.ExportToFile(filePath);
}
Restore a Database
string constr = "server=localhost;user=root;pwd=1234;database=test1;convertzerodatetime=true;";
string filePath = @"C:\backup.sql";

using (var conn = new MySqlConnection(constr))
using (var cmd = conn.CreateCommand())
using (var mb = new MySqlBackup(cmd))
{
    conn.Open();
    mb.ImportFromFile(filePath);
}

Why MySqlBackup.NET?

Unlike MySQL Workbench (developer-focused) or MySqlDump.exe (restricted in web environments), MySqlBackup.NET offers:

  • End-User Simplicity: Preset parameters for a one-click backup experience.
  • Web Compatibility: Runs seamlessly in ASP.NET, bypassing hosting restrictions on executables.
  • Programmatic Control: Fine-tuned output handling within .NET.

Dependencies

MySqlBackup.NET requires one of these MySQL connectors:

Connector Source License DLLs
MySqlConnector MySqlConnector MIT MySqlConnector.dll
MySql.Data MySQL Connector/Net GPL MySql.Data.dll
Devart Express dotConnect for MySQL Custom (FAQ) Devart.Data.dll, Devart.Data.MySql.dll

Configuration Tips

Unicode Support

For databases with UTF-8 or Unicode characters (e.g., À, Ñ, Cyrillic, Chinese), use:

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

Or, for broader support:

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

DateTime Handling (MySql.Data Only)

To avoid conversion errors with null or date-only values, add:

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

Performance Benchmark

Compare MySqlBackup.NET to MySqlDump for a 3.5GB database (15M rows):

Task Tool Time File Size
Backup MySqlDump ~2m 35s 4.66 GB
Backup MySqlBackup.NET ~7m 48s 4.59 GB
Restore MySql.exe ~8m 41s -
Restore MySqlBackup.NET ~9m 41s -

Full details: Performance Benchmark Wiki


Additional Tools

Backup All Databases
Export all databases to separate SQL files with this sub-project:
MySqlBackup_All_DB


License

MySqlBackup.NET is released under The Unlicense, making it free for any use.


Conclusion

MySqlBackup.NET empowers developers and end-users alike with a robust, .NET-native solution for MySQL database management. Whether for desktop apps, web services, or automated backups, it’s a versatile addition to your toolkit.

Explore more on GitHub!

Product 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 is compatible.  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.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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 is compatible. 
.NET Framework net461 was computed.  net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (15)

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.

Senparc.Ncf.Database.MySql.Backup

Senparc.Ncf.Database.MySql.Backup

MyDapper

Dapper的操作帮助类

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
logicpulse/logicPOS
Logicpulse's Open Source POS 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.
Version Downloads Last Updated
2.6.1 120 7/4/2025
2.6.0 135 7/4/2025
2.3.9 8,500 3/12/2025
2.3.8 127,082 3/7/2023
2.3.7 104,670 10/18/2022
2.3.6.1 155,795 10/20/2021
2.3.6 4,534 10/17/2021
2.3.5.3 4,318 9/24/2021
2.3.5.2 1,508 9/23/2021
2.3.5.1 1,587 9/22/2021
2.3.4.2 9,171 7/30/2021
2.3.4.1 6,395 7/12/2021
2.3.4 89,708 3/10/2021
2.3.3.1 45,642 7/16/2020
2.3.1 325,979 8/23/2019
2.3.0.1 10,085 7/26/2019
2.3.0 5,250 6/24/2019
2.2.1 16,374 4/7/2019
2.2.0 1,986 4/7/2019
2.1.0 15,201 12/1/2018
2.0.12.1 10,899 8/28/2018
2.0.12 26,039 3/26/2018
2.0.11.1 6,017 2/7/2018
2.0.11 2,664 2/7/2018
2.0.10.1 5,356 12/2/2017
2.0.10 4,331 12/1/2017
2.0.9.5 53,838 11/19/2016
2.0.9.4 8,620 3/20/2016
2.0.9.3 9,624 1/9/2016
2.0.9.2 6,736 8/8/2015
2.0.9.1 2,995 7/24/2015
2.0.9 2,807 7/19/2015
2.0.8 37,059 2/24/2015
2.0.7.1 18,318 1/26/2015
2.0.6 3,181 11/21/2014
2.0.5.1 2,826 10/20/2014
2.0.5 2,514 10/20/2014
2.0.4 4,212 5/12/2014
2.0.3 2,631 5/11/2014
2.0.2.1 3,431 4/10/2014