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
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.
- 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.
Grab the latest release from: GitHub Releases
Install via NuGet Package Manager:
-
MySqlConnector:
PM> Install-Package MySqlBackup.NET.MySqlConnector
https://www.nuget.org/packages/MySqlBackup.NET.MySqlConnector/ -
MySql.Data Connector:
PM> Install-Package MySqlBackup.NET
https://www.nuget.org/packages/MySqlBackup.NET/ -
Devart Express Connector:
PM> Install-Package MySqlBackup.Net.DevartExpress
https://www.nuget.org/packages/MySqlBackup.Net.DevartExpress/
See the detailed guide:
How to Add This Library into Your Project
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);
}
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);
}
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.
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 |
We aim for MySqlBackup.NET to achieve 100% SQL compliance, ensuring seamless compatibility with mysqldump
and mysql.exe
for both backup and restore operations. Version 2.6 introduces key improvements, addressing some flaws in previous version and compatibility challenges with mysqldump
-generated files. If you encounter any incompatibilities, we welcome feedback via GitHub Issues to help us refine and uphold this goal.
- Always use the default character set of
utf8mb4
, orutf8
in older MySQL versions that do not supportutf8mb4
. - It is recommended to use
convertzerodatetime=true
in the connection string for compatibility when handling null datetime values.
For a 416 MB database (400,000 rows, 4 tables, InnoDB) on an Intel Core i7-4770S (3.10GHz, 16GB RAM, SSD Samsung 870 Evo 500GB):
Task | Tool | Avg. Time | File Size |
---|---|---|---|
Backup | MySqlBackup.NET (Parallel) | ~10.21s | 571.588 MB |
Backup | MySqlBackup.NET (Single) | ~15.72s | 571.588 MB |
Backup | mysqldump.exe | ~6.76s | 566.976 MB |
Restore | MySqlBackup.NET | ~35.87s | - |
Restore | mysql.exe | ~32.76s | - |
MySqlBackup.NET v2.6 offers competitive performance, especially in parallel mode, with significant improvements over previous versions. Full details: Performance Benchmark Wiki.
MySqlBackup.NET is released under The Unlicense, making it free for any use.
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, built by a global community for a global community.
Explore more on GitHub!