Skip to content
betterstack-alchemyUnofficial

Cloud.MySQLScheduledSnapshot

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

A schedule that snapshots a managed MySQL instance at a regular interval. Free to define: the snapshots are what is stored.

frequency (hourly, daily, weekly or monthly, a calendar month) changes in place; a new mysqlId replaces the schedule. Deleting the instance removes its schedules with it. Snapshots themselves are stored (and billed) by Better Stack; see the database snapshots docs for retention and restore.

Ownership. The API keeps no metadata for it and it has no generated name, so nothing marks it as this stack’s: list enumerates it under every parent, and a create interrupted before its state was saved is not recognised by the next deploy (which creates it again, or gets the API’s conflict when its identity is unique).

What it leaves behind. The snapshots it takes are not resources of this stack: deleting the schedule (or the instance) keeps them, and they stay billed (“Snapshots outlive their database”). Remove them in Databases → Snapshots or with the SDK’s listFlatMysqlSnapshot / deleteFlatMysqlSnapshot.

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.

Daily snapshots of an instance

const db = yield* BetterStack.Cloud.MySQL("db", { type: "MY1" });
yield* BetterStack.Cloud.MySQLScheduledSnapshot("daily", {
mysqlId: db.id,
frequency: "daily",
});

Reference a schedule by id

const existing = BetterStack.Cloud.MySQLScheduledSnapshot.lookup({ mysqlId: "42", id: "7" });

frequency "monthly" | "hourly" | "daily" | "weekly" | string required

How often we create a snapshot. A month is a calendar month.

mysqlId string required

The ID of the MySQL instance the schedule belongs to.

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.

availabilityZone string always set

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

id string always set

The schedule's ID.

mysqlId string always set

The ID of the [MySQL](/reference/cloud/mysql/) instance it snapshots.

createdAt string

When the schedule was created.

frequency "monthly" | "hourly" | "daily" | "weekly"

How often we create a snapshot. A month is a calendar month.

lastRunAt string | null

When the schedule last created a snapshot, or null before the first one.

serverId string

The ID of the server that runs the instance's current primary, which changes when the instance fails over.

updatedAt string

When the schedule was last updated.

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

id string required

The schedule's ID.

mysqlId string required

The ID of the [MySQL](/reference/cloud/mysql/) instance.

availabilityZone string

Zone the instance lives in. Defaults to the credentials' zone.