Cubicle

Snapshots

Cubicle snapshots are offline, disk-only copies of a stopped Box stored on its Node, used to restore the Box in place or create new Boxes, with rules for status, sizing, organization snapshots, hibernation and retention.

A snapshot is a named, point-in-time copy of a stopped Box's disk. You can restore the Box to it later, or create new Boxes from it. Taking, restoring and listing snapshots are covered step by step in Snapshot and restore a Box; this page explains what a snapshot is and the rules around it.

What a snapshot captures

A snapshot is a copy of the Box's root disk. It does not capture anything that lives only in memory.

CapturedNot captured
Every file on the root disk: the operating system and installed softwareMemory and running processes
The home directory of every user who has had access to the BoxOpen network connections and SSH sessions
The guest accounts as they exist on the diskThe Box's name, size, private IP address or grants
A copy of the Linux kernel the Box boots, which Cubicle suppliesSaved hibernation memory (see below)
  • A snapshot is offline: the Box must be fully stopped while it is taken, so the disk is consistent.
  • Size is not stored with the snapshot. A Box created from it starts from the source Box's current size (see Size rules).

Requirements

RequirementRule
Box stateThe Box must be stopped. Otherwise the request fails with 409 conflict "stop the box before taking a snapshot".
Fully stoppedThe Node also checks that the Box is actually stopped when it runs the snapshot. Wait for state: "stopped" at the current generation.
Hibernated BoxesA hibernated Box is not stopped. Stop it first, which discards its saved memory, then take the snapshot.
PermissionA grant on the Box, or the owner or admin role in its organization. API keys need the write scope.
NameMatches ^[a-z0-9][a-z0-9._-]{0,62}$, for example before-upgrade. Names do not have to be unique, so refer to snapshots by id.

If you request a snapshot before the Box has finished stopping, the snapshot operation can fail with "box must be stopped". The SDK's box.stop() and the CLI's cubicle boxes stop --wait wait for the stopped state for you. See Box lifecycle for states and generations.

While a snapshot or restore is pending or running, start, stop, hibernate and delete requests for that Box fail with 409 conflict "a snapshot or restore is in progress for this box".

Status

A snapshot request returns an operation of type snapshot. The snapshot record appears in the Box's snapshot list as soon as the request is accepted, and its status follows the operation.

statusMeaning
pendingThe operation is pending or running. The snapshot cannot be used yet.
completeThe operation finished as done. You can restore from it or create Boxes from it.
failedThe operation did not finish as done; its error says why. The snapshot can never be used.

Any member of the Box's organization can list a Box's own snapshots, with GET /v1/boxes/{box}/snapshots or the SDK's box.listSnapshots(). The list shows every snapshot of that Box in every status, including pending and failed ones, newest first. Each entry has id, name, status, operationId, createdAt and completedAt. The SDK's box.snapshot(name) waits for the operation and returns the Snapshot.

Where snapshots live

  • A snapshot is stored on the Box's Node. It is not copied to other Nodes or to remote storage, so it is not a backup: it shares a Node with its Box and is deleted with it.
  • A Box created from a snapshot is therefore placed on the snapshot's Node. If that Node is unavailable or has no room for the new Box, creation fails with 503 capacity.

Restore in place or create a Box from a snapshot

You can use a complete snapshot in two ways.

Restore in placeCreate a Box from a snapshot
RequestPOST /v1/boxes/{box}/restore with snapshotId; box.restore(snapshotId)POST /v1/orgs/{org}/boxes with snapshotId; cubicle.boxes.create({ snapshotId })
Which snapshotsOnly this Box's own snapshotsAny snapshot in the same organization whose source Box still exists
PermissionA grant on the Box, or owner or adminA grant on the source Box, or owner or admin; the organization must allow Box creation
Box stateThe Box must be stoppedThe source Box can be in any state
ResultThe same Box: its ID, name, private IP address, grants and SSH host key stayA new Box with a new ID, hostname, private IP address and SSH host key
DiskReplaced with the snapshot's disk. Current disk contents are lost.A copy of the snapshot's disk, grown to the requested diskGiB
KernelThe Box keeps booting its current kernelBoots the kernel stored in the snapshot
SizeUnchangedSee Size rules
AccessCurrent grants and SSH keys are applied again before the Box accepts loginsOnly you have a grant on the new Box
Returns202 with an operation of type restore202 with the new Box
AfterwardThe Box stays stopped. Start it when the operation is done.The Box starts unless you pass start: false

What a restore changes

  • The disk is replaced in one step, so an interrupted restore never leaves a half-written disk.
  • Every guest account is applied again from current access. A restored disk cannot bring back access that was revoked after the snapshot: accounts without a current grant are locked when the Box starts.

What a Box created from a snapshot gets

The Node copies the snapshot's disk for the new Box right away, even when you create it with start: false. Until that copy is done, deleting the source Box fails with 409 conflict "box NAME is still being created from a snapshot of this box". After it, the new Box is independent of the source Box and its snapshots.

The new Box's disk still holds every home directory from the source Box. Other users' accounts stay locked, because only you hold a grant, but anyone with sudo in the new Box can read their files. Remove data you do not want copied before you take the snapshot.

To prepare a Box once and create others from its snapshot, see Build a template Box.

Size rules for a Box created from a snapshot

FieldDefaultRule
baseImageThe source Box's base imageCannot be set together with snapshotId: the request fails with 400 invalid_request.
vcpusThe source Box's current vCPUsAny value from 1 to 64.
memoryMiBThe source Box's current memoryAny value from 256 to 262144 MiB.
diskGiBThe source Box's current diskAt least the source Box's disk, up to 2048 GiB. A smaller value fails with 400 invalid_request "disk must be at least N GiB (the snapshot's size)".

A larger disk is grown, together with its file system, before the new Box first boots. A disk can never shrink. The new Box's name follows the usual Box name rules.

Organization snapshots

To find snapshots you can create Boxes from, list the organization's snapshots with GET /v1/orgs/{org}/snapshots or the SDK's cubicle.listSnapshots().

  • The list holds only complete snapshots whose source Box has not been deleted.
  • An owner or admin sees every such snapshot in the organization.
  • A member sees snapshots of the Boxes they hold a grant on, because creating a Box from a snapshot copies that Box's data.
  • Each entry has id, name, createdAt, the source box (id, name), its node and the source Box's spec, so you can choose a source and a size.

Snapshots and hibernation

Hibernation also saves state, but it is not a snapshot. Box lifecycle explains hibernation in full.

HibernationSnapshot
What it savesMemory, running processes and device state, inside the Box's own disk imageThe disk only
Box stateTaken from a running BoxTaken from a stopped Box
How manyAt most one per BoxAny number per Box
Named, listedNoYes
Used byThe next start, which resumes the BoxA restore, or creating a new Box
Discarded byStopping the BoxDeleting the Box

Retention and deletion

  • Snapshots are kept until their Box is deleted. There is no API to delete a single snapshot.
  • Deleting a Box deletes all of its snapshots. You can no longer restore from them or create Boxes from them.
  • To keep a disk after deleting its Box, create a Box from one of its snapshots first. Deleting the source Box fails until the new Box's copy of the disk is done.

On this page