Пример #1
0
        public async Task FullBackupDataDirectory()
        {
            var path = GetStringQueryString("path", required: true);
            var requestTimeoutInMs = GetIntValueQueryString("requestTimeoutInMs", required: false) ?? 5 * 1000;
            var getNodesInfo       = GetBoolValueQueryString("getNodesInfo", required: false) ?? false;

            await BackupConfigurationHelper.GetFullBackupDataDirectory(path, requestTimeoutInMs, getNodesInfo, ServerStore, ResponseBodyStream());
        }
Пример #2
0
        public async Task PutServerWideBackupConfigurationCommand()
        {
            using (ServerStore.ContextPool.AllocateOperationContext(out TransactionOperationContext context))
            {
                var configurationBlittable = await context.ReadForMemoryAsync(RequestBodyStream(), "server-wide-backup-configuration");

                var configuration = JsonDeserializationCluster.ServerWideBackupConfiguration(configurationBlittable);

                ServerStore.LicenseManager.AssertCanAddPeriodicBackup(configuration);
                BackupConfigurationHelper.UpdateLocalPathIfNeeded(configuration, ServerStore);
                BackupConfigurationHelper.AssertBackupConfiguration(configuration);
                BackupConfigurationHelper.AssertDestinationAndRegionAreAllowed(configuration, ServerStore);

                var(newIndex, _) = await ServerStore.PutServerWideBackupConfigurationAsync(configuration, GetRaftRequestIdFromQuery());

                await ServerStore.WaitForCommitIndexChange(RachisConsensus.CommitIndexModification.GreaterOrEqual, newIndex);

                using (var writer = new BlittableJsonTextWriter(context, ResponseBodyStream()))
                    using (context.OpenReadTransaction())
                    {
                        var backupName = ServerStore.Cluster.GetServerWideBackupNameByTaskId(context, newIndex);
                        if (backupName == null)
                        {
                            throw new InvalidOperationException($"Backup name is null for server-wide backup with task id: {newIndex}");
                        }

                        var putResponse = new PutServerWideBackupConfigurationResponse()
                        {
                            Name             = backupName,
                            RaftCommandIndex = newIndex
                        };

                        HttpContext.Response.StatusCode = (int)HttpStatusCode.Created;
                        context.Write(writer, putResponse.ToJson());
                        writer.Flush();
                    }
            }
        }