Skip to content
betterstack-alchemyUnofficial

Cloud.MySQLSnapshot

Kind ResourceType id BetterStack.Cloud.MySQLSnapshotSource src/Cloud/MySQLSnapshot.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/MySQLSnapshot.test.ts).

An on-demand snapshot of a managed MySQL instance: “We flush MySQL’s data to disk first, so the snapshot is consistent.” The deploy waits until the snapshot is available (a failed one fails with WaitFailed and is removed again).

Snapshots and schedules. A MySQLScheduledSnapshot 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 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 mysqlId 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_mysql_snapshot creates a new instance from the snapshot (new IDs, hostname and passwords) and restore_mysql rolls the origin instance back. Neither fits a prop, and MySQL’s create takes no snapshot id to pair with, so nothing here restores; call Cloud.restoreMysqlSnapshot 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.MySQL("db", { type: "MY1" });
const beforeMigration = yield* BetterStack.Cloud.MySQLSnapshot("before-migration", {
mysqlId: db.id,
name: "orders-before-migration",
metadata: { reason: "migration" },
});

By name under an instance

const existing = BetterStack.Cloud.MySQLSnapshot.lookup({
mysqlId: "42",
name: "orders-before-migration",
});

mysqlId string required

The ID of the MySQL instance to snapshot.

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 followed by the date, such as orders-2026-11-24.

availabilityZone string always set

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

id string always set

The snapshot's ID, a UUID.

mysqlId string always set

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

createdAt string

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

failureReason string | null

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

lock MysqlSnapshotLock | null

The lock Better Stack put on the snapshot, with its reason, or null when the snapshot isn't locked.

metadata unknown

Your tags, as an object of string keys and values.

name string

The snapshot's name.

serverId string | null

The ID of the server that ran the instance's primary when the snapshot was taken, or null once that server is removed.

sizeBytes number | null

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

snapshotType string

How the snapshot was created.<br/>Valid values:<br/>manual: You created the snapshot.<br/>scheduled: A snapshot schedule created it.

status string

The snapshot's state.<br/>Valid values:<br/>pending: We're creating the snapshot.<br/>available: The snapshot is ready, and you can restore it.<br/>failed: We couldn't create the snapshot. failure_reason says why.<br/>deleting: We're deleting the snapshot.

updatedAt string

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

MySQLSnapshot.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.

mysqlId string

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