예제 #1
0
        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);
            }
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
		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);
			}
		}
예제 #4
0
		public static void Restore(RavenConfiguration configuration, string backupLocation, string databaseLocation)
		{
			using (var transactionalStorage = configuration.CreateTransactionalStorage(() => { }))
			{
				transactionalStorage.Restore(backupLocation, databaseLocation);
			}
		}
예제 #5
0
		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);
			}
		}