Skip to content
betterstack-alchemyUnofficial

Cloud.PostgresScheduledSnapshot

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

A schedule that snapshots a managed Postgres 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 postgresId 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 listFlatPostgresSnapshot / deleteFlatPostgresSnapshot.

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.Postgres("db", { type: "PG1" });
yield* BetterStack.Cloud.PostgresScheduledSnapshot("daily", {
postgresId: db.id,
frequency: "daily",
});

Reference a schedule by id

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

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

How often we create a snapshot. A month is a calendar month, so its length varies.

postgresId string required

The ID of the PostgreSQL instance.

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.

postgresId string always set

The ID of the [Postgres](/reference/cloud/postgres/) 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, so its length varies.

lastRunAt string | null

When the schedule last ran, or null until the schedule first runs.

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.

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

id string required

The schedule's ID.

postgresId string required

The ID of the [Postgres](/reference/cloud/postgres/) instance.

availabilityZone string

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