Skip to content
betterstack-alchemyUnofficial

Cloud.ClickHouseSnapshot

Kind ResourceType id BetterStack.Cloud.ClickHouseSnapshotSource src/Cloud/ClickHouseSnapshot.tsLive test gated Lifecycle test runs against the offline mock; a live run exists but is gated behind BETTERSTACK_TEST_CLOUD_BILLABLE=1 because it bills; live runs need the owner's go-ahead (test/Cloud/ClickHouseSnapshot.test.ts).

An on-demand snapshot of a managed ClickHouse instance: “The snapshot holds the data inserted before it, except rows still in Buffer tables.” The deploy waits until the snapshot is available (a failed one fails with WaitFailed and is removed again).

Snapshots and schedules. A ClickHouseScheduledSnapshot is a schedule that takes snapshots of the same kind (snapshotType: "scheduled") on its own; this resource is one manual snapshot, taken when it is created and kept until it is destroyed. Snapshots a schedule took are never managed or listed by this resource.

Cost. The snapshot bills by sizeBytes (“The size of the instance’s disk when the snapshot was taken, in bytes. We bill by this size.”); “Database snapshots are billed like server snapshots and share their quotas.”

Replace, never update. The API has no update for it: a new name, metadata or clickhouseId takes a new snapshot and deletes the old one. The snapshot outlives its instance (deleting the instance keeps it), so it is read and deleted by its own id.

Restore is not modelled. Restoring is an action, not desired state: restore_clickhouse_snapshot creates a new instance from the snapshot (new IDs, hostname and passwords) and restore_clickhouse rolls the origin instance back. Neither fits a prop, and ClickHouse’s create takes no snapshot id to pair with, so nothing here restores; call Cloud.restoreClickhouseSnapshot from betterstack-alchemy/sdk/services when you need one.

Ownership. The alchemy marker in metadata identifies the snapshots this stack created: an interrupted create is found again by the next deploy, and list returns only Alchemy-created snapshots.

Zone. A child doesn’t take its zone from its parent: it uses its own availabilityZone, else the credentials’ zone. When the parent lives in another zone, pass the parent’s along (availabilityZone: parent.availabilityZone), or every call for it answers NotFound.

A snapshot before a risky migration

const db = yield* BetterStack.Cloud.ClickHouse("db", { type: "CH1" });
const beforeMigration = yield* BetterStack.Cloud.ClickHouseSnapshot("before-migration", {
clickhouseId: db.id,
name: "analytics-before-migration",
metadata: { reason: "migration" },
});

By name under an instance

const existing = BetterStack.Cloud.ClickHouseSnapshot.lookup({
clickhouseId: "42",
name: "analytics-before-migration",
});

clickhouseId string required

The ID of the ClickHouse instance to create a snapshot of.

availabilityZone string

Availability zone the resource lives in, such as us-west-2a. Defaults to the credentials' zone (BETTERSTACK_AVAILABILITY_ZONE, or the profile's). Changing it replaces the resource. A child of a resource in another zone (a firewall rule, a node pool, a snapshot of an instance outside the credentials' zone) must repeat the parent's availabilityZone: it receives only the parent's id, so its zone cannot be derived.

metadata Record<string, string>

Your own tags, as string keys and values. Can't be changed after the snapshot is created: a change replaces the snapshot.

name string

The snapshot's name. Defaults to the instance's name and the date, such as analytics-2026-11-24.

availabilityZone string always set

Availability zone the resource lives in, such as us-west-2a.

clickhouseId string always set

The ID of the [ClickHouse](/reference/cloud/clickhouse/) instance the snapshot was taken from.

id string always set

The snapshot's ID, a UUID.

createdAt string

When the snapshot was created. In ISO 8601 format, such as 2026-07-01T12:00:00Z.

failureReason string | null

Why creating the snapshot failed, or null unless the snapshot is failed.

lock ClickhouseSnapshotLock | null

Our lock on the snapshot, or null when it isn't locked. You can still delete and restore a locked snapshot.

metadata unknown

Your own tags as string pairs.

name string

The snapshot's name.

serverId string | null

The ID of the server that runs the instance. The server is hidden from your list of servers. Can become null after the instance is deleted.

sizeBytes number | null

The size of the instance's disk when the snapshot was taken, in bytes. We bill by this size. Stays null until the snapshot is ready.

snapshotType string

How the snapshot was created.<br/>Valid values:<br/>manual: Created by a request.<br/>scheduled: Created by a snapshot schedule.

status string

The snapshot's state.<br/>Valid values:<br/>pending: We're creating the snapshot. The snapshot then becomes available, or failed with a failure_reason.<br/>available: The snapshot is ready to restore.<br/>failed: We couldn't create the snapshot. failure_reason says why.<br/>deleting: We're deleting the snapshot's data. The snapshot is gone once we're done.

updatedAt string

When the snapshot was last updated. In ISO 8601 format, such as 2026-07-01T12:00:00Z.

ClickHouseSnapshot.lookup(props) reads an object this stack does not manage. It is never created, updated or deleted.

availabilityZone string

Zone, such as us-west-2a. Defaults to the credentials' zone.

clickhouseId string

The instance's ID (not needed to find it: snapshots are addressed by id). Only snapshots of this instance.