This content is part of a third party extension that is not supported by the Cake project.
For more information about this extension see
Cake.SqlServer.
Summary
Backup an existing database to a file.
Syntax
public static void BackupDatabase(this ICakeContext context, string connectionString, string databaseName, BackupDatabaseSettings settings)
Examples
#addin "nuget:?package=Cake.SqlServer"
Task("Backup-Database")
.Does(() =>
{
var connString = @"data source=(localdb)\MSSqlLocalDb";
var databaseName = "MyDatabase";
BackupDatabase(connString, databaseName, new BackupDatabaseSettings()
{
Compress = false,
Path = System.IO.Path.GetTempPath() // place files in Temp folder
});
});
Attributes
Type |
Description |
CakeMethodAliasAttribute |
|
Parameters
Name |
Type |
Description |
context |
ICakeContext |
The Cake context. |
connectionString |
string |
The connection string. Regardless of the database specified, the connection will switch to master database for this operation. |
databaseName |
string |
Database to backup. |
settings |
BackupDatabaseSettings |
Settings for backing up database. |
Return Value