/APIs & SDKs/Programs and frameworks/snapshots

OptiTech CLI command: snapshots

Create, list, restore, and schedule branch snapshots from the terminal

The snapshots command creates, lists, updates, deletes, and restores snapshots of your OptiTech branches, and manages the automatic backup schedule of a branch. A snapshot captures the state of a branch at a point in time, so you can restore it later. For background on the feature, plans, and limits, see Backup and restore.

If --project-id is omitted, the CLI resolves it from your context file, auto-selects when your account has only one project, and prompts otherwise.

Subcommands: create, delete, finalize, get, list, restore, schedule, update

optitech snapshots create

Creates a snapshot from a branch. By default, it snapshots the head of the branch from your context or the project's default branch. Use --lsn or --timestamp to capture an earlier point within the branch's restore window; the two options are mutually exclusive.

optitech snapshots create [options]
OptionDescriptionTypeDefaultRequired
--branch, -bBranch id or name to snapshot. Defaults to the branch in your context, or the project's default branch.stringNo
--expires-atWhen the snapshot is automatically deleted (RFC 3339, e.g. 2025-12-31T23:59:59Z). Omit to keep it indefinitely.stringNo
--lsnTake the snapshot at this LSN (e.g. 0/1F3C8A0). Must fall within the branch's restore window. Mutually exclusive with --timestamp.stringNo
--nameA name for the snapshotstringNo
--timestampTake the snapshot at this point in time (RFC 3339, e.g. 2025-01-01T00:00:00Z). Must fall within the branch's restore window. Mutually exclusive with --lsn.stringNo
--project-idProject IDstringNo

Snapshot the head of a branch with a name:

optitech snapshots create --branch main --name pre-migration

Snapshot a branch at a specific LSN and set an expiration:

optitech snapshots create --branch main --lsn 0/1F3C8A0 --expires-at 2025-12-31T23:59:59Z

Snapshot a branch at a point in time:

optitech snapshots create --branch main --timestamp 2025-01-01T00:00:00Z

Timestamps and expiration times use RFC 3339 format. Omit --expires-at to keep the snapshot indefinitely.

optitech snapshots list

Lists the snapshots in a project.

optitech snapshots list [options]
OptionDescriptionTypeDefaultRequired
--project-idProject IDstringNo
optitech snapshots list

optitech snapshots get

Retrieves a snapshot by ID or name.

optitech snapshots get <id> [options]
OptionDescriptionTypeDefaultRequired
--project-idProject IDstringNo
optitech snapshots get snap-1234

optitech snapshots update

Renames a snapshot or changes its expiration. Use --clear-expiration to keep a snapshot indefinitely; it's mutually exclusive with --expires-at.

optitech snapshots update <id> [options]
OptionDescriptionTypeDefaultRequired
--clear-expirationClear the expiration so the snapshot is kept indefinitely.booleanNo
--expires-atSet when the snapshot expires (RFC 3339). Mutually exclusive with --clear-expiration.stringNo
--nameRename the snapshotstringNo
--project-idProject IDstringNo

Rename a snapshot:

optitech snapshots update snap-1234 --name pre-migration

Clear a snapshot's expiration:

optitech snapshots update snap-1234 --clear-expiration

optitech snapshots delete

Deletes a snapshot by ID or name.

optitech snapshots delete <id> [options]
OptionDescriptionTypeDefaultRequired
--project-idProject IDstringNo
optitech snapshots delete snap-1234

optitech snapshots restore

Restores a snapshot into a branch. By default, the restore is left un-finalized so you can inspect the restored branch first, then swap it in with snapshots finalize. Pass --finalize to move computes onto the restored branch and swap it in for the target immediately.

optitech snapshots restore <id> [options]
OptionDescriptionTypeDefaultRequired
--finalizeFinalize the restore immediately: move computes onto the restored branch and swap it in for the target. Without this, the restore is left un-finalized so you can inspect it first, then run snapshots finalize <branch>.booleanfalseNo
--nameName for the newly restored branch. Auto-generated when omitted.stringNo
--target-branchBranch id or name to restore the snapshot onto. Defaults to the snapshot's source branch. Recommended when you intend to finalize (replace an existing branch).stringNo
--project-idProject IDstringNo

Restore a snapshot to a new branch:

optitech snapshots restore snap-1234 --name recovered

Restore onto an existing branch un-finalized to preview, then finalize:

optitech snapshots restore snap-1234 --target-branch main

Restore onto a branch and swap it in immediately:

optitech snapshots restore snap-1234 --target-branch main --finalize

optitech snapshots finalize

Finalizes a previewed snapshot restore, swapping the restored branch in for the target. Use this after running snapshots restore without --finalize. The argument is the ID of the restored branch that snapshots restore created, not the target branch. The restore command prints the exact finalize command to run.

optitech snapshots finalize <branch> [options]
OptionDescriptionTypeDefaultRequired
--nameName to give the replaced (old) branch. Auto-generated when omitted.stringNo
--project-idProject IDstringNo
optitech snapshots finalize br-summer-water-au2msxjn

The replaced (old) branch is kept under an auto-generated name unless you set one with --name.

Snapshot schedule

The snapshots schedule subcommands get and set the automatic snapshot (backup) schedule of a branch.

Subcommands: get, set

optitech snapshots schedule get

Gets a branch's automatic snapshot schedule.

optitech snapshots schedule get [options]
OptionDescriptionTypeDefaultRequired
--branch, -bBranch id or name. Defaults to the branch in your context, or the project's default branch.stringNo
--project-idProject IDstringNo
optitech snapshots schedule get --branch main

optitech snapshots schedule set

Sets a branch's automatic snapshot schedule. Build a single-entry schedule with --frequency and its companion flags, or pass a full JSON schedule with --schedule for a multi-entry schedule (this overrides the single-entry flags).

Pick one --frequency; that choice determines which of --day and --hour you must also set. The supported frequencies are:

--frequencyAlso required--day range
daily--hour (0-23)not used
weekly--day, --hour1-7 (Monday-Sunday)
monthly--day, --hour1-31

Use --retention with any frequency to set how long each snapshot is kept.

optitech snapshots schedule set [options]
OptionDescriptionTypeDefaultRequired
--branch, -bBranch id or name. Defaults to the branch in your context, or the project's default branch.stringNo
--dayDay of the week/month (1-31) to take the snapshot (used with --frequency).numberNo
--frequencyHow often to take snapshots. Combine with --hour, --day, and --retention to build a single-entry schedule. Possible values: daily, weekly, monthlystringNo
--hourHour of the day (0-23) to take the snapshot (used with --frequency).numberNo
--monthMonth of the year (1-12) to take the snapshot (used with --frequency).numberNo
--retentionHow long to keep each snapshot, in seconds (min 3600). Omit to keep indefinitely.numberNo
--scheduleFull schedule as JSON, for multi-entry schedules, e.g. '[{"frequency":"daily","hour":3,"retention_seconds":604800}]'. Overrides the single-entry flags.stringNo
--project-idProject IDstringNo

Set a daily 03:00 snapshot kept for 7 days (604800 seconds):

optitech snapshots schedule set --branch main --frequency daily --hour 3 --retention 604800

Set a weekly snapshot on Mondays at 04:00:

optitech snapshots schedule set --branch main --frequency weekly --day 1 --hour 4

Set a multi-entry schedule with JSON:

optitech snapshots schedule set --branch main --schedule '[{"frequency":"daily","hour":3},{"frequency":"weekly","day":1,"hour":4}]'

Retention is set in seconds (minimum 3600). Omit --retention to keep snapshots indefinitely.

Was this page helpful?