> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ubiquex.io/llms.txt
> Use this file to discover all available pages before exploring further.

# ubx rollback

> Roll back the stack to the state from a previous apply.

`ubx rollback` computes the diff between the current deployed state and a target snapshot, then prompts to confirm and apply the rollback. The target can be a date or a git SHA prefix.

## Usage

```bash theme={"theme":"css-variables","languages":{"custom":["/languages/xcl.json"]}}
ubx rollback <date-or-sha> [flags]
```

## Flags

| Flag        | Description                                          |
| ----------- | ---------------------------------------------------- |
| `--dry-run` | Show the diff and exit without prompting or applying |

## Arguments

| Argument | Description                            |
| -------- | -------------------------------------- |
| `<date>` | Date in `YYYY-MM-DD` format            |
| `<sha>`  | Git SHA prefix (at least 6 characters) |

## Examples

```bash theme={"theme":"css-variables","languages":{"custom":["/languages/xcl.json"]}}
ubx rollback 2026-06-15            # roll back to state on that date
ubx rollback abc1234               # roll back to state at git SHA
ubx rollback --dry-run 2026-06-15  # preview without applying
```

## What happens

1. Loads the apply history from `ubx-history.json` (or legacy SQLite)
2. Finds the snapshot matching the date or SHA
3. Computes the diff between that snapshot and the current state
4. Displays the diff
5. Prompts `Apply rollback to "<target>"? [y/N]` unless `--dry-run`

## Dry-run output

```
  Rollback to 2026-06-15

  Resources that would change:
  - aws_s3_bucket.assets-bucket  (remove)
  + aws_vpc.old-vpc               (recreate at old config)
  ~ aws_rds_instance.database     (change instance_class: m5.large → t3.micro)
```

## Rollback note

After confirming, ubx records the rollback intent but does not automatically apply it. The next step is:

1. Revert the relevant `.xcl` files to match the target state
2. Run `ubx ship` to apply the changes

ubx currently records the rollback plan as a guide — full automated state rollback (without re-running codegen) is planned for a future release.

## Exit codes

| Code | Meaning                              |
| ---- | ------------------------------------ |
| `0`  | Rollback plan displayed (or applied) |
| `1`  | No history found, or user cancelled  |
