0

Update service backup configuration

by
Published Oct 17, 2025

Updates service backup configuration. Requires ADMIN auth key role. Setting the properties with null value, will reset the properties to theirs default values.

Script clickhouse Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Clickhouse = {
3
  username: string;
4
  password: string;
5
  host: string;
6
};
7
/**
8
 * Update service backup configuration
9
 * Updates service backup configuration. Requires ADMIN auth key role. Setting the properties with null value, will reset the properties to theirs default values.
10
 */
11
export async function main(
12
  auth: Clickhouse,
13
  organizationId: string,
14
  serviceId: string,
15
  body: {
16
    backupPeriodInHours?: number;
17
    backupRetentionPeriodInHours?: number;
18
    backupStartTime?: string;
19
  }
20
) {
21
  const url = new URL(
22
    `https://api.clickhouse.cloud/v1/organizations/${organizationId}/services/${serviceId}/backupConfiguration`
23
  );
24

25
  const response = await fetch(url, {
26
    method: "PATCH",
27
    headers: {
28
      "Content-Type": "application/json",
29
      Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
30
    },
31
    body: JSON.stringify(body),
32
  });
33
  if (!response.ok) {
34
    const text = await response.text();
35
    throw new Error(`${response.status} ${text}`);
36
  }
37
  return await response.json();
38
}
39