public MigrationInfo CreateMigration(string name) { var masterSnap = CombineMigrations(_rootFolder); var snapshotFolder = Path.Combine(_rootFolder, string.Format("{0}_{1}", DateTime.Now.ToString("yyyyMMdd_HHmmss"), name.ToSafeFileName())); uSyncBackOfficeContext.Instance.ExportAll(snapshotFolder); LogHelper.Info <MigrationManager>("Export Complete"); foreach (var folder in _folders) { var source = IOHelper.MapPath("~/" + folder); if (Directory.Exists(source)) { LogHelper.Info <MigrationManager>("Including {0} in snapshot", () => source); var target = Path.Combine(snapshotFolder, folder); MigrationIO.MergeFolder(target, source); } } LogHelper.Info <MigrationManager>("Extra folders copied"); // now we delete anything that is in any of the previous snapshots. if (!string.IsNullOrEmpty(masterSnap)) { // Capture deletes since last snapshot // things in the master but not in our new one, must have // gone missing (delete?) IdentifyDeletes(masterSnap, snapshotFolder); // take anything that is now in our snapshotFolder and masterSnapshot // this will leave just the changes.. MigrationIO.RemoveDuplicates(snapshotFolder, masterSnap); Directory.Delete(masterSnap, true); } LogHelper.Info <MigrationManager>("Cleaned Snapshot up.."); if (!Directory.Exists(snapshotFolder)) { // empty snapshot LogHelper.Info <MigrationManager>("No changes in this snapshot"); } return(new MigrationInfo(snapshotFolder)); }