Skip to main content
Snapshots are backups of an app’s or database’s storage. Apps and databases share the same three methods:
  • c.Apps.Snapshots: List(ctx, appID), Create(ctx, appID), Restore(ctx, appID, name, versionID)
  • c.Databases.Snapshots: List(ctx, databaseID), Create(ctx, databaseID), Restore(ctx, databaseID, name, versionID)
How many snapshots you can create per day depends on your plan (see Limits). Each snippet below runs on its own inside this program: paste one at a time into main and run goimports (see Running the examples).

Listing snapshots

Creating a snapshot

Create waits for the snapshot (without a ctx deadline, at least 2 minutes before timing out). A large snapshot may not finish in time: the API then answers 202 and the SDK returns a SnapshotCreated with Pending set to true and a nil error. The snapshot keeps generating and shows up in List on its own, usually within 2 minutes.
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(ctx, id, name, versionID) takes the Name and VersionID of a listed snapshot.

Downloading a snapshot

c.DownloadSnapshot(ctx, url, w) streams a snapshot file from its signed url (from List or Create) into any io.Writer. It does not call the API: the API key is never sent to the storage host, and the URL never appears in the returned error. Nothing is buffered in memory, and there is no default deadline (bound or cancel it with ctx). A network error before the response is retried like any GET.
An expired or invalid URL returns an *APIError with the storage host’s HTTP status and UNKNOWN_ERROR. A URL that cannot be parsed, and an error of your io.Writer, are returned as plain errors.

Account snapshots

c.Account.Snapshots(ctx, scope) lists every snapshot of the account. Pass "" for all of them, or squarecloud.SnapshotScopeApplications or squarecloud.SnapshotScopeDatabases. It needs an active plan and shares the network endpoints’ rate limit (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, deleting the app or starting the database is 403 RESTORE_IN_PROGRESS.

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.