Skip to main content
Snapshots are copies of an app’s or database’s storage. Apps and databases share the same four methods:
  • api.apps.snapshots: list(appId), create(appId), restore(appId, name, versionId), restoreState(appId)
  • api.databases.snapshots: list(databaseId), create(databaseId), restore(databaseId, name, versionId), restoreState(databaseId)
How many snapshots you can create per day depends on your plan (see Limits). Examples use the api client from Creating the client. appId is the id of one of your apps: api.account.me() lists them.

Listing snapshots

An empty list means there are no snapshots. When snapshot storage cannot answer, list() and account.snapshots() throw 503 SNAPSHOTS_UNAVAILABLE instead. The SDK does not retry it: try again in about 30 seconds.

Creating a snapshot

create() waits for the snapshot (at least 120 s before timing out). A large snapshot may not finish in time: the API then answers 202 and the SDK returns { pending: true }. The snapshot keeps generating and shows up in list() on its own, usually within 2 minutes.
An API key without the snapshots:read scope gets { pending: false } with url and key as "".
Never call create() again to check on a pending snapshot: it starts a new one and counts against the plan’s daily snapshot quota. Poll list() instead.

Restoring a snapshot

restore(id, name, versionId) takes the name and version_id of a listed snapshot. It resolves to { pending: false } when the restore has finished. A restore that takes longer than about 90 seconds resolves to { pending: true } and keeps running.

Following a long restore

restoreState(id) reports the latest restore of the app or database. You can call it up to 30 times a minute. started_at and finished_at are Unix ms.
Never call restore() again to check on a pending restore. Poll restoreState() instead.

Downloading a snapshot

api.downloadSnapshot(url, { signal }) streams a snapshot file from its signed url (from list() or create()). It does not call the API: the API key is never sent to the storage host. It returns a ReadableStream<Uint8Array>, with nothing buffered in memory, and has no timeout (pass a signal).
An expired or invalid URL throws a SquareCloudAPIError with the storage host’s HTTP status and UNKNOWN_ERROR.

Account snapshots

api.account.snapshots({ scope }) lists the snapshots of all your apps ("applications", the default) or of all your databases ("databases"). It needs an active plan and is limited to 3 calls a minute (429 RATE_LIMITED).

Limits

  • create() is limited to one call per 180 seconds and to a daily quota that depends on the plan: going over the quota is 429 DAILY_SNAPSHOTS_LIMIT_REACHED.
  • While a restore runs, delete(), start(), stop() and restart() of that app or database, and snapshot create(), throw 409 RESTORE_IN_PROGRESS, and status() reports restoring: true.
  • The SDK never retries 409 SNAPSHOT_IN_PROGRESS or 503 CLUSTER_MAINTENANCE_TRY_LATER from create() and restore().

Next steps

Databases

Create and manage databases.

Snapshot API reference

The REST endpoints behind these methods.

Snapshots from the CLI

The same actions from the terminal.