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
Restores a database from a backup file.
Syntax
public static void RestoreSqlBackup(this ICakeContext context, string connectionString, FilePath backupFile, RestoreSqlBackupSettings settings)
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, new RestoreSqlBackupSettings()
{
NewDatabaseName = "RestoredFromTest.Cake",
NewStorageFolder = new DirectoryPath(System.IO.Path.GetTempPath()), // place files in Temp folder
WithReplace = true, // tells sql server to discard non-backed up data when overwriting existing database
});
});
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 |
settings |
RestoreSqlBackupSettings |
Settings for restoring database |
Return Value