Inheritance: IDisposable
Esempio n. 1
0
		public void Backup_and_restore_of_system_database_should_work()
		{
			using (var ravenServer = GetNewServer(runInMemory: false,requestedStorage:"esent"))
			using (var _ = NewRemoteDocumentStore(ravenDbServer: ravenServer, databaseName: "fooDB", runInMemory: false))
			{
			    using (var systemDatabaseBackupOperation = new BackupOperation
			                                            {
			                                                BackupPath = BackupDir,
			                                                Database = Constants.SystemDatabase,
			                                                ServerUrl = ravenServer.SystemDatabase.Configuration.ServerUrl
			                                            })
			    {

			        Assert.True(systemDatabaseBackupOperation.InitBackup());
			        WaitForBackup(ravenServer.SystemDatabase, true);
			    }
			}

			Assert.DoesNotThrow(() => MaintenanceActions.Restore(new RavenConfiguration(), new RestoreRequest
			{
			    BackupLocation = BackupDir,
                DatabaseLocation = DataDir
			}, s => { }));

		}
Esempio n. 2
0
        private void Initialize()
        {
	        op = new BackupOperation
	        {
		        NoWait = false,
		        Incremental = false
	        };

	        optionSet = new OptionSet
	        {
		        {"url=", "RavenDB server {0:url}", url => op.ServerUrl = url},
		        {"dest=", "Full {0:path} to backup folder", path => op.BackupPath = path},
		        {"nowait", "Return immediately without waiting for a response from the server", _ => op.NoWait = true},
		        {"readkey", "Specifying this flag will make the utility wait for key press before exiting.", _ => doReadKeyOnExit = true},

				{"d|database:", "The database to operate on. If no specified, the operations will be on the default database.", value => op.Database = value},
				{"u|user|username:"******"The username to use when the database requires the client to authenticate.", value => op.Credentials.UserName = value},
				{"p|pass|password:"******"The password to use when the database requires the client to authenticate.", value => op.Credentials.Password = value},
				{"domain:", "The domain to use when the database requires the client to authenticate.", value => op.Credentials.Domain = value},
				{"key|api-key|apikey:", "The API-key to use, when using OAuth.", value => op.ApiKey = value},
		        {"incremental", "When specified, the backup process will be incremental when done to a folder where a previous backup lies. If dest is an empty folder, or it does not exist, a full backup will be created. For incremental backups to work, the configuration option Raven/Esent/CircularLog must be set to false.", _ => op.Incremental = true},
				{"timeout:", "The timeout to use for requests", s => op.Timeout = int.Parse(s)},
			    {"h|?|help", v =>
			    {
				    PrintUsage();
					Environment.Exit(0);
			    }},
	        };
        }
Esempio n. 3
0
		static void Main(string[] args)
		{
			var doReadKeyOnExit = false;
			var op = new BackupOperation { NoWait = false };
			var incrementalBackup = false;
			var optionSet = new OptionSet
			                	{
			                		{"url=", "RavenDB server {0:url}", url => op.ServerUrl = url},
			                		{"dest=", "Full {0:path} to backup folder", path => op.BackupPath = path},
			                		{"nowait", "Return immedialtey without waiting for a response from the server", _ => op.NoWait = true},
			                		{"readkey", _ => doReadKeyOnExit = true},
									{"incremental", s => incrementalBackup= true}
			                	};

			try
			{
				if (args.Length == 0)
					PrintUsage(optionSet);

				optionSet.Parse(args);
			}
			catch (Exception e)
			{
				Console.WriteLine("Could not understand arguemnts");
				Console.WriteLine(e.Message);
				PrintUsage(optionSet);
				return;
			}

			op.Incremental = incrementalBackup;
			if (string.IsNullOrWhiteSpace(op.ServerUrl))
			{
				Console.WriteLine("Enter RavenDB server URL:");
				op.ServerUrl = Console.ReadLine();
			}

			if (string.IsNullOrWhiteSpace(op.BackupPath))
			{
				Console.WriteLine("Enter backup destination:");
				op.BackupPath = Console.ReadLine();
			}

			if (string.IsNullOrWhiteSpace(op.BackupPath) || string.IsNullOrWhiteSpace(op.ServerUrl))
				return;

			try
			{
				if (op.InitBackup())
					op.WaitForBackup();
			}
			catch (Exception ex)
			{
				Console.WriteLine(ex);
			}

			if (doReadKeyOnExit) Console.ReadKey();
		}
Esempio n. 4
0
		static void Main(string[] args)
		{
			var doReadKeyOnExit = false;
			var op = new BackupOperation { NoWait = false };
			var incrementalBackup = false;
			var optionSet = new OptionSet
			                	{
			                		{"url=", "RavenDB server {0:url}", url => op.ServerUrl = url},
			                		{"dest=", "Full {0:path} to backup folder", path => op.BackupPath = path},
			                		{"nowait", "Return immediately without waiting for a response from the server", _ => op.NoWait = true},
			                		{"readkey", "Specifying this flag will make the utility wait for key press before exiting.", _ => doReadKeyOnExit = true},
									{"incremental", "When specified, the backup process will be incremental when done to a folder where a previous backup lies. If dest is an empty folder, or it does not exist, a full backup will be created. For incremental backups to work, the configuration option Raven/Esent/CircularLog must be set to false.", s => incrementalBackup= true}
			                	};

			try
			{
				if (args.Length == 0)
					PrintUsage(optionSet);

				optionSet.Parse(args);
			}
			catch (Exception e)
			{
				Console.WriteLine("Could not understand arguments");
				Console.WriteLine(e.Message);
				PrintUsage(optionSet);
				return;
			}

			op.Incremental = incrementalBackup;
			if (string.IsNullOrWhiteSpace(op.ServerUrl))
			{
				Console.WriteLine("Enter RavenDB server URL:");
				op.ServerUrl = Console.ReadLine();
			}

			if (string.IsNullOrWhiteSpace(op.BackupPath))
			{
				Console.WriteLine("Enter backup destination:");
				op.BackupPath = Console.ReadLine();
			}

			if (string.IsNullOrWhiteSpace(op.BackupPath) || string.IsNullOrWhiteSpace(op.ServerUrl))
				return;

			try
			{
				if (op.InitBackup())
					op.WaitForBackup();
			}
			catch (Exception ex)
			{
				Console.WriteLine(ex);
			}

			if (doReadKeyOnExit) Console.ReadKey();
		}
Esempio n. 5
0
		public void Backup_and_restore_of_system_database_should_work()
		{
			using(var ravenServer = GetNewServer(requestedStorage:"esent",runInMemory:false))
			using (var _ = NewRemoteDocumentStore(ravenDbServer: ravenServer, databaseName: "fooDB", runInMemory: false,fiddler:true))
			{
				var systemDatabaseBackupOperation = new BackupOperation
				{
					BackupPath = BackupDir,
					Database =  Constants.SystemDatabase,
					ServerUrl = ravenServer.Server.Configuration.ServerUrl
				};

				Assert.True(systemDatabaseBackupOperation.InitBackup());
				WaitForBackup(ravenServer.Server.SystemDatabase,true);
			}

			Assert.DoesNotThrow(() => DocumentDatabase.Restore(new RavenConfiguration(), BackupDir, DataDir, s => { }, defrag: false));

		}
Esempio n. 6
0
        static void Main(string[] args)
        {
            var doReadKeyOnExit = false;
            var op = new BackupOperation {
                NoWait = false
            };
            var incrementalBackup = false;
            var optionSet         = new OptionSet
            {
                { "url=", "RavenDB server {0:url}", url => op.ServerUrl = url },
                { "dest=", "Full {0:path} to backup folder", path => op.BackupPath = path },
                { "nowait", "Return immedialtey without waiting for a response from the server", _ => op.NoWait = true },
                { "readkey", _ => doReadKeyOnExit = true },
                { "incremental", s => incrementalBackup = true }
            };

            try
            {
                if (args.Length == 0)
                {
                    PrintUsage(optionSet);
                }

                optionSet.Parse(args);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                PrintUsage(optionSet);
                return;
            }

            op.Incremental = incrementalBackup;
            if (string.IsNullOrWhiteSpace(op.ServerUrl))
            {
                Console.WriteLine("Enter RavenDB server URL:");
                op.ServerUrl = Console.ReadLine();
            }

            if (string.IsNullOrWhiteSpace(op.BackupPath))
            {
                Console.WriteLine("Enter backup destination:");
                op.BackupPath = Console.ReadLine();
            }

            if (string.IsNullOrWhiteSpace(op.BackupPath) || string.IsNullOrWhiteSpace(op.ServerUrl))
            {
                return;
            }

            try
            {
                if (op.InitBackup())
                {
                    op.WaitForBackup();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            if (doReadKeyOnExit)
            {
                Console.ReadKey();
            }
        }
Esempio n. 7
0
        static void Main(string[] args)
        {
            var doReadKeyOnExit = false;
            var op = new BackupOperation {
                NoWait = false
            };
            var incrementalBackup = false;
            var optionSet         = new OptionSet
            {
                { "url=", "RavenDB server {0:url}", url => op.ServerUrl = url },
                { "dest=", "Full {0:path} to backup folder", path => op.BackupPath = path },
                { "nowait", "Return immedialtey without waiting for a response from the server", _ => op.NoWait = true },
                { "readkey", "Specifying this flag will make the utility wait for key press before exiting.", _ => doReadKeyOnExit = true },
                { "incremental", "When specified, the backup process will be incremental when done to a folder where a previous backup lies. If dest is an empty folder, or it does not exist, a full backup will be created. For incremental backups to work, the configuration option Raven/Esent/CircularLog must be set to false.", s => incrementalBackup = true }
            };

            try
            {
                if (args.Length == 0)
                {
                    PrintUsage(optionSet);
                }

                optionSet.Parse(args);
            }
            catch (Exception e)
            {
                Console.WriteLine("Could not understand arguemnts");
                Console.WriteLine(e.Message);
                PrintUsage(optionSet);
                return;
            }

            op.Incremental = incrementalBackup;
            if (string.IsNullOrWhiteSpace(op.ServerUrl))
            {
                Console.WriteLine("Enter RavenDB server URL:");
                op.ServerUrl = Console.ReadLine();
            }

            if (string.IsNullOrWhiteSpace(op.BackupPath))
            {
                Console.WriteLine("Enter backup destination:");
                op.BackupPath = Console.ReadLine();
            }

            if (string.IsNullOrWhiteSpace(op.BackupPath) || string.IsNullOrWhiteSpace(op.ServerUrl))
            {
                return;
            }

            try
            {
                if (op.InitBackup())
                {
                    op.WaitForBackup();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            if (doReadKeyOnExit)
            {
                Console.ReadKey();
            }
        }