BackupAliases.

RestoreSqlBackup(ICakeContext, string, FilePath) Method

Summary

Restores a database from a backup file.
Assembly
Cake.SqlServer.dll
Namespace
Cake.SqlServer
Containing Type
BackupAliases

Syntax

public static void RestoreSqlBackup(this ICakeContext context, string connectionString, FilePath backupFile)

Examples

    #addin "nuget:?package=Cake.SqlServer"

    Task("Restore-Database")
        .Does(() =>
        {
            var connString = @"data source=(localdb)\MSSqlLocalDb";
            var backupFile = new FilePath("C:/tmp/myBackup.bak");
            RestoreSqlBackup(connString, backupFile); 
        });

Attributes

Type Description
CakeMethodAliasAttribute

Parameters

Name Type Description
context ICakeContext The Cake context.
connectionString string The connection string. You may want to connect to master database for this operation.
backupFile FilePath Absolute path to .bak file

Return Value

Type Description
void