public static void Restore(RavenConfiguration configuration, DatabaseRestoreRequest restoreRequest, Action <string> output) { var databaseDocumentPath = FindDatabaseDocument(restoreRequest.BackupLocation); if (File.Exists(databaseDocumentPath) == false) { throw new InvalidOperationException("Cannot restore when the Database.Document file is missing in the backup folder: " + restoreRequest.BackupLocation); } var databaseDocumentText = File.ReadAllText(databaseDocumentPath); var databaseDocument = RavenJObject.Parse(databaseDocumentText).JsonDeserialization <DatabaseDocument>(); string storage; if (databaseDocument.Settings.TryGetValue("Raven/StorageTypeName", out storage) == false) { storage = "esent"; } if (!string.IsNullOrWhiteSpace(restoreRequest.DatabaseLocation)) { configuration.DataDirectory = restoreRequest.DatabaseLocation; } using (var transactionalStorage = configuration.CreateTransactionalStorage(storage, () => { })) { transactionalStorage.Restore(restoreRequest, output); } }
public static void Restore(RavenConfiguration configuration, DatabaseRestoreRequest restoreRequest, Action <string> output) { var databaseDocumentPath = FindDatabaseDocument(restoreRequest.BackupLocation); if (File.Exists(databaseDocumentPath) == false) { throw new InvalidOperationException("Cannot restore when the Database.Document file is missing in the backup folder: " + restoreRequest.BackupLocation); } if (File.Exists(Path.Combine(restoreRequest.BackupLocation, Constants.BackupFailureMarker))) { throw new InvalidOperationException("Backup failure marker was detected. Unable to restore from given directory."); } var databaseDocumentText = File.ReadAllText(databaseDocumentPath); var databaseDocument = RavenJObject.Parse(databaseDocumentText).JsonDeserialization <DatabaseDocument>(); string storage; if (databaseDocument.Settings.TryGetValue("Raven/StorageTypeName", out storage) == false) { if (File.Exists(Path.Combine(restoreRequest.BackupLocation, BackupMethods.Filename))) { storage = InMemoryRavenConfiguration.VoronTypeName; } else if (Directory.Exists(Path.Combine(restoreRequest.BackupLocation, "new"))) { storage = InMemoryRavenConfiguration.EsentTypeName; } else { storage = InMemoryRavenConfiguration.EsentTypeName; } } if (!string.IsNullOrWhiteSpace(restoreRequest.DatabaseLocation)) { configuration.DataDirectory = restoreRequest.DatabaseLocation; } using (var transactionalStorage = configuration.CreateTransactionalStorage(storage, () => { }, () => { })) { transactionalStorage.Restore(restoreRequest, output); } }
public static void Restore(RavenConfiguration configuration, string backupLocation, string databaseLocation, Action<string> output, bool defrag) { using (var transactionalStorage = configuration.CreateTransactionalStorage(() => { })) { if (!string.IsNullOrWhiteSpace(databaseLocation)) { configuration.DataDirectory = databaseLocation; } transactionalStorage.Restore(backupLocation, databaseLocation, output, defrag); } }
public static void Restore(RavenConfiguration configuration, string backupLocation, string databaseLocation) { using (var transactionalStorage = configuration.CreateTransactionalStorage(() => { })) { transactionalStorage.Restore(backupLocation, databaseLocation); } }
public static void Restore(RavenConfiguration configuration, string backupLocation, string databaseLocation, Action<string> output, bool defrag = true) { using (var transactionalStorage = configuration.CreateTransactionalStorage(() => { })) { transactionalStorage.Restore(backupLocation, databaseLocation, output, defrag); } }