Skip to main content

Backup MySQL Database by ASP.Net MVC Actions

Backup MySQL Database by ASP.Net MVC Actions

In some cases, it can be convenient to be able to backup database directly from your WebApp.

The purpose of this tutorial is to implement a DbBackupController containing 3 actions :

  • Sql (SQL dump plain text)
  • DownloadSql (SQL dump in file)
  • DownloadZip (SQL dump in zip file)

We will use the following libraries (All are available as NuGet packages) :

  • MySql.Data
  • SharpZipLib
  • MySqlBackup.NET

Implementation

IDbBackupService

DbBackupService

ZipHelper

DbBackupController