public void TestBackup() { var engine = new CloudBackup.Backup.Engine(); engine.RootPath = @"C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\"; using (var backup = engine.CreateBackup()) { backup.CreateShadowCopy(); var snapRoot = backup.GetSnapshotPath(); var ret = backup.GetSnapshotElements(); backup.DropBackup(); } }
public static void RunBackup(ArchiveJob job,bool forceFullBackup, string reason) { log.InfoFormat("Starting backup of [{0}]", job.JobRootPath); using (var process = new Process(job, forceFullBackup, reason)) { try { process.BuildConnectBackend(); var engine = new Engine { RootPath = job.JobRootPath }; using (var backup = engine.CreateBackup()) { //- First create a snapshot process.BuildSnapshot(backup); //- Publish ZIP file process.PublishZipFile(backup); } log.InfoFormat("Process completed - Commit Transaction"); process.CommitTransaction(); // Post process if (job.JobTarget.ManageTargetFiles) { process.ClearUnneededFiles(); } } catch(Exception ex) { process._proxy.Transaction.Rollback(); process._proxy = null; log.Error("Process failed ! - Rollback Transaction", ex); process._report.AppendLine("** FAILED ** Exception: " + ex); var proxy = Program.Database.CreateSnapProxy(); proxy.BackupReport(job.JobUID.Value, process._now.Ticks, false,reason, process._report.ToString()); proxy.Transaction.Commit(); } } }