BackupAliases.

BackupDatabase(ICakeContext, string, string, BackupDatabaseSettings) Method

Summary

Backup an existing database to a file.
Assembly
Cake.SqlServer.dll
Namespace
Cake.SqlServer
Containing Type
BackupAliases

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

Type Description
void