/// <param name="rootPath"> /// Root path under which per-database backup folders are found; the folder names must match database names exactly. /// </param> /// <param name="targetTime"> /// Optional, point in time to restore to; latest if null /// </param> /// <param name="worker"> /// Optional, to report progress to and implement cancellation from. /// </param> /// <param name="targetServer"> /// Self-explanatory /// </param> /// <param name="namingConvention"> /// Defines historical backup directory structure. /// </param> public MultiRestorer(string rootPath, DateTime?targetTime, BackgroundWorker worker, string targetServer, IBackupDirectoryNamingConvention namingConvention) { Check.DoRequireArgumentNotNull(rootPath, "rootPath"); Check.DoRequireArgumentNotNull(targetServer, "targetServer"); Check.DoRequireArgumentNotNull(namingConvention, "namingConvention"); NamingConvention = namingConvention; RootPath = rootPath; TargetTime = targetTime; _worker = worker; var bld = new SqlConnectionStringBuilder() { IntegratedSecurity = true, DataSource = targetServer, InitialCatalog = "master", ConnectTimeout = 2, // seconds; }; // keep same connection to be able to use single user mode for databases when restoring var conn = new ServerConnection(new SqlConnection(bld.ToString())); Server = new Server(conn); Server.ConnectionContext.StatementTimeout = 0; // read actual names var existingLogins = string.Join(", ", Server.Logins.Cast <Login>().Select(x => x.Name)); Log.InfoFormat("Existing logins: {0}", existingLogins); }
public BackupFileCatalog( IBackupDirectoryNamingConvention namingConvention , string databaseBackupFolder) { Check.DoRequireArgumentNotNull(namingConvention, "namingConvention"); Check.DoRequireArgumentNotNull(databaseBackupFolder, "databaseBackupFolder"); NamingConvention = namingConvention; DatabaseBackupDirectory = new DirectoryInfo(databaseBackupFolder); Check.DoCheckArgument(DatabaseBackupDirectory.Exists, () => string.Format("Backup folder {0} does not exist", databaseBackupFolder)); _backupFileFolders = GetBackupFolders(); }