Scale, upgrade and roll back

Once an application is deployed, five verbs cover day two. Two of them edit your application.yaml for you, so read this page before you run them.

VerbEdits the spec?New generation?
statusnono
restartnono
scaleyesyes
upgradeyesyes
rollbacknoyes (N+1)

Restart

sg application restart --config application.yaml            # every owned instance
sg application restart --config application.yaml web       # one group
sg application restart --config application.yaml web-1     # one instance, by key
Restart application instances hello-web-1? This interrupts service. [y/N]:
application hello restart run <run-id> finished: 1 instance(s) restarted and verified; no generation recorded.

Restart re-runs the health checks afterwards. A selector that matches nothing refuses.

Scale a group

scale changes a group's count and placements, writes the result into application.yaml, then runs the normal deploy pipeline. You must give the complete resulting placement, one --target per resulting instance:

sg application scale --config application.yaml web --count 3 \
  --target web-0=node-a --target web-1=node-b --target web-2=node-c --dry-run

--dry-run shows the edited spec and the resulting deploy plan without writing a file or touching a host:

Application group web scale preview (no file or host changes).
…
Plan hash: …

Happy with it? Drop --dry-run:

sg application scale --config application.yaml web --count 3 \
  --target web-0=node-a --target web-1=node-b --target web-2=node-c
Scale application group web and deploy the resulting plan? [y/N]:

A successful deploy records a new generation. Scaling down removes the highest-numbered instances; --count 0 is allowed.

Upgrade a group

Ship a new image to a group:

sg application upgrade --config application.yaml web --image hello-web-2 --dry-run
sg application upgrade --config application.yaml web --image hello-web-2
Upgrade application group web (image hello-web-2) and deploy the resulting plan? [y/N]:

An image change recreates the group's instances, so the plan grades it high. Container data that isn't on a volume goes with the old instance.

Upgrade a service

Move a database to a newer release within its major version:

sg application upgrade --config application.yaml db --service postgres --version <newer-17.x-package-version> --dry-run
sg application upgrade --config application.yaml db --service postgres --version <newer-17.x-package-version>

The --dry-run plan shows the exact version that would be installed. Major-version moves change the on-disk format, so expect sg to refuse them on a volume that already holds data.

--version follows the same rules as in the spec: never latest; for PostgreSQL a major or an exact package version, for ClickHouse an exact release. A change that isn't safe for the data already on the volume refuses with sg:service-version-incompatible. You can combine --image and --version in one upgrade; at least one is required.

Service version upgrades are CLI-only. The panel's upgrade takes an image only.

Roll back

sg application rollback --config application.yaml

Rollback takes the exact spec recorded with generation N-1 and deploys it as a new generation N+1. It tells you what it picked before it asks:

rollback: application hello selects generation 1 and plans generation 3 from its recorded bytes; individual steps are not undone and data volumes are reattached, not restored.

and when it's done:

rollback: application hello redeployed generation 1 as generation 3 (run <run-id>); data volumes are reattached, not touched.

Three things to understand:

  • It's a redeploy, not an undo. Individual steps aren't reversed. The old spec is applied fresh.
  • Data isn't restored. Volumes are reattached as they are now. Rollback doesn't bring back yesterday's rows.
  • It only goes back one. No generation N-1, or an invalid one, means sg:rollback-unavailable. It never falls back further. Run rollback again and you're going back one from the new generation.

See the history

The panel lists generations, newest first, at GET /api/v1/applications/<name>/generations. Failed and aborted deploys show up in run history (/api/v1/runs) but never as generations. See The admin panel.