| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
A dependency-free C# library for MySQL backup and restore, built as a new foundation for the successor to MySqlBackup.NET.
It speaks the MySQL wire protocol directly. Exported row values stay as bytes: numbers pass through unchanged, text is escaped, and binary values become SQL hex literals. No ADO.NET driver, DataTable, or per-cell DateTime/decimal/string conversion.
Targets .NET Framework 4.8, .NET Standard 2.0, and .NET 8. The library has no third-party runtime dependencies.
Build the solution and reference src/MySqlBackup.RawBytes/MySqlBackup.RawBytes.csproj.
using System;
using System.IO;
using MySqlBackup.RawBytes;
using (var connection = MySqlConnection.Open(new ConnectionOptions
{
Host = "db.example.com",
User = "backup_user",
Password = Environment.GetEnvironmentVariable("MYSQL_PASSWORD"),
Database = "app"
}))
{
using (var file = File.Create("app.sql"))
new BackupEngine(connection).Export("app", file);
}To restore, open a connection with the existing target database selected:
using (var file = File.OpenRead("app.sql"))
new RestoreEngine(connection).Restore(file);Use BackupOptions for schema/data selection, object selection, row layout, and MaxInsertBytes. Wrap the output in GZipStream for compression.
dotnet build MySqlBackup.RawBytes.sln -c Release
dotnet run --project tests/MySqlBackup.RawBytes.Tests -c Release -f net8.0The console suite asserts protocol framing, parsing, escaping, limits, and allocations. Live integration tests verify exact restored values, schema objects, concurrent-write snapshots, TLS, and interoperability with mysql and mysqldump. Any failure returns a nonzero exit code.
Tested with MySQL 8.0.34; view dependency discovery requires MySQL 8.0.13 or newer. Other server versions and MariaDB are not yet certified. This is a new API, not a drop-in replacement for MySqlBackup.NET.
Prevent schema changes during export. The default snapshot requires InnoDB; quiesce other engines before choosing BackupConsistency.None. Memory scales with the largest row/statement, not the whole database. Restore is not atomic, and definers and external schema references must be valid on the target. See design and limitations.
The Unlicense — public domain.
| Back | FazBrowse Home | New Git URL |