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 multiple backup files.
Syntax
public static void RestoreMultipleSqlBackup(this ICakeContext context, string connectionString, RestoreSqlBackupSettings settings, IList<FilePath> backupFiles, IList<FilePath> differentialBackupFiles = null)
Examples
#addin "nuget:?package=Cake.SqlServer"
Task("Restore-Split-Database")
.Does(() =>
{
var connString = @"data source=(localdb)\MSSqlLocalDb";
var backupFile1 = new FilePath("C:/tmp/myBackup1.bak");
var backupFile2 = new FilePath("C:/tmp/myBackup2.bak");
var backupFileList = new List<FilePath> {backupFile1, backupFile2};
var diffBackupFile1 = new FilePath("C:/tmp/myDiffBackup1.bak");
var diffBackupFile2 = new FilePath("C:/tmp/myDiffBackup2.bak");
var diffBackupFileList = new List<FilePath> {diffBackupFile1, diffBackupFile2};
RestoreMultipleSqlBackup(connString, 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
BackupSetFile = 1, // tells which backup set file to use for backupFile*
DifferentialBackupSetFile = 1, // tells which backup set file to use for diffBackupFile*
}, backupFileList, diffBackupFileList);
});
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. |
settings |
RestoreSqlBackupSettings |
Settings for restoring database |
backupFiles |
IList<FilePath> |
Absolute path to (multiple) .bak files |
differentialBackupFiles |
IList<FilePath> |
Absolute path to (multiple) additional differential .bak files |
Return Value