public int Restore() { VdiEngine BackupDevice = new VdiEngine(); BackupDevice.CommandIssued += new EventHandler <CommandIssuedEventArgs>(BackupDevice_CommandIssued); BackupDevice.InfoMessageReceived += new EventHandler <InfoMessageEventArgs>(BackupDevice_InfoMessageReceived); using (var RestoreStream = UriStreamUtil.GetUriStream(Options)) { using (DeflateStream CompressedRestoreStream = new DeflateStream(RestoreStream, CompressionMode.Decompress)) { DateTime Start = DateTime.Now; BackupDevice.ExecuteCommand(string.Join(Environment.NewLine, "ALTER DATABASE [" + Options.Database + "] SET SINGLE_USER WITH ROLLBACK IMMEDIATE", "RESTORE DATABASE [" + Options.Database + "] FROM VIRTUAL_DEVICE = '{0}' WITH REPLACE, STATS = 1", "ALTER DATABASE[" + Options.Database + "] SET MULTI_USER" ), CompressedRestoreStream); Console.WriteLine(DateTime.Now.Subtract(Start)); } } return(0); }
public int Verify() { VdiEngine BackupDevice = new VdiEngine(); BackupDevice.CommandIssued += new EventHandler <CommandIssuedEventArgs>(BackupDevice_CommandIssued); BackupDevice.InfoMessageReceived += new EventHandler <InfoMessageEventArgs>(BackupDevice_InfoMessageReceived); using (var VerifyStream = UriStreamUtil.GetUriStream(Options)) { using (DeflateStream CompressedRestoreStream = new DeflateStream(VerifyStream, CompressionMode.Decompress)) { DateTime Start = DateTime.Now; BackupDevice.ExecuteCommand("RESTORE VERIFYONLY FROM VIRTUAL_DEVICE = '{0}' WITH STATS = 1", CompressedRestoreStream); Console.WriteLine(DateTime.Now.Subtract(Start)); } } return(0); }