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

# Upgrade a self-hosted install to 3.0

> Back up a 2.x installation, add the credential pepper, deploy 3.0, run the vault data move by hand, and keep a snapshot-based rollback.

A 3.0 upgrade has two parts: deploy the release and its database migrations, then run the vault data move yourself. Starting the containers does not run the data move.

Schedule a maintenance window. Rehearse the entire process on an isolated restored copy first. Don't upgrade the only copy of your data without a tested snapshot restore.

> [!WARNING]
>
> Self-hosted 3.0 is for one person. Organization-wide secrets and connections
> are not used after the move. Their rows stay in the database, but agents
> cannot use them as vault items. Add each credential you still need to each
> vault that needs it. The move does not copy those values for you or reject the
> upgrade just because they exist.

## What changes

| Before 3.0 | In 3.0 |
| - | - |
| Workspaces and agent-specific access | Vaults with item permissions shared by every agent on that vault. The move can split a workspace when its agents had different access. |
| Plain stored person API keys | Managing-key rows that hold hashes after the move. Existing key strings keep working. You cannot reveal a key again. |
| Reusable older agent tokens | Existing `aoc_` tokens keep working. Disconnect and reconnect an agent to replace one. New agents receive their own `oc_agent_` credential. |
| Organization-wide credentials | Unused on a self-hosted install after the move. Add the needed credentials to each vault again. |
| Older CLI and API workflows | Upgrade your CLI and review scripts. The old key reveal and regeneration workflow is not how you create a new managing key. |
| Agent credential on a person's call | Answers `403` with `code: person_required`, not `401`. A script that treated `401` as "sign in again" should treat this as "wrong credential". |

An agent gets every allowed item in its vault, including items added later. Put agents with different access on separate vaults. Read the [trust model](/docs/guides/trust-model.md) for the remaining token, network, and response-echo limits.

**1. Save a complete rollback snapshot**

Pause agents and management writes. Record your current image tags or digests, Compose file, and configuration. Take a consistent database snapshot and save the gateway's `app-data` volume and instance secrets from the same maintenance point.

Store the backup encrypted and restrict access. A 2.x database can contain readable API keys and older agent tokens. Don't put a database dump, `.env`, or gateway private key in a support ticket or shared log.

Confirm that you can restore the snapshot into an isolated environment using the old release. Keep the original snapshot unchanged throughout the upgrade.

**2. Add the credential pepper before starting 3.0**

The API and gateway need the same `CREDENTIAL_PEPPER_SECRET`. It must have at least 32 characters. It is separate from `SECRET_ENCRYPTION_KEY`: one protects credential hashes, the other encrypts stored values.

Re-running the installer adds a missing pepper. For a manual upgrade, add it once to your existing installation's `.env`:

```bash theme={null}
ENV_FILE="$HOME/.onecli/.env"
grep -q '^CREDENTIAL_PEPPER_SECRET=' "$ENV_FILE" || \
  printf 'CREDENTIAL_PEPPER_SECRET=%s\n' "$(head -c 32 /dev/urandom | base64)" >> "$ENV_FILE"
chmod 600 "$ENV_FILE"
```

For a source checkout, use the `docker/.env` file instead. If a pepper line already exists but is empty or invalid, fix it before continuing. Don't generate a new value over a working one.

Keep `SECRET_ENCRYPTION_KEY`, `GATEWAY_INTERNAL_SECRET`, and `BETTER_AUTH_SECRET` unchanged. Back up the new pepper too. If you already have `CREDENTIAL_PEPPER_SECRET_OLD` or `SECRET_ENCRYPTION_KEYS_OLD`, keep those values on every relevant service.

The current Compose file requires the pepper before startup. With an older Compose file, a server may start without it but credential checks fail closed. A running container alone is not proof that the keys work.

**3. Deploy the pinned 3.0 release and migrations**

Use the published 3.0 release tag you intend to run. Don't use `latest` for a controlled upgrade. The installer refreshes the Compose file as well as the images:

```bash theme={null}
export ONECLI_VERSION=3.0.0
curl -fsSL https://onecli.sh/install | sh
```

Use this command only once that release is published. The explicit export matters: the installer otherwise selects `latest`, which can override a pin written only in `.env`. Confirm that your saved configuration records the release you chose for future restarts.

If you upgrade by hand, obtain the Compose file for the new release first, add the pepper, and set `ONECLI_VERSION` in the installation's `.env`. From `~/.onecli` for an installer-managed stack:

```bash theme={null}
cd ~/.onecli
docker compose -p onecli pull
docker compose -p onecli up -d --wait
docker compose -p onecli logs migrations
```

From a source checkout, use its `docker/` directory. The one-shot migrations service runs `prisma migrate deploy`. The API waits for it to complete successfully. The migrations add the schema required for vault access, hashed credentials, and item metadata. They do not perform the vault data move.

If migrations fail, stop here. Inspect the migrations service's error and resolve it before starting dependent services. Don't delete migration history or mark an unknown failed migration as applied to bypass the failure.

**4. Run the read-only checks and dry run**

Keep agents and management writes paused. Run the command from `/app` as the API image's normal user, not as root. In the installation directory:

```bash theme={null}
umask 077
docker compose -p onecli exec -T -w /app api \
  node apps/api-server/dist/vault-move.mjs --check-links

docker compose -p onecli exec -T -w /app api \
  node apps/api-server/dist/vault-move.mjs --verify > vault-access-before.txt

docker compose -p onecli exec -T -w /app api \
  node apps/api-server/dist/vault-move.mjs
```

The command without flags is a dry run. It plans the move and writes nothing. It uses `DATABASE_URL` and `SECRET_ENCRYPTION_KEY` already supplied to the API container. Hashing old keys also needs the pepper and `GATEWAY_INTERNAL_URL`. The current Compose file supplies the internal gateway address and `GATEWAY_INTERNAL_SECRET`.

Read the full output and exit status. The report prints IDs and counts, not names or credential values. A summary excerpt can look like this:

```text theme={null}
workspaces to move: 2
workspaces skipped (already vaults): 0
vaults kept: 2
vaults made: 1
organization items left unused (this build cannot share them): 2
plain keys before: 1
plain keys to hash: old workspace keys 1, old organization keys 0
plain keys left: 0
```

Treat the unused organization-item count as an access change you must address, not as a successful copy. Keep the report and before-check file private because resource IDs and access relationships are still sensitive.

### Resolve refusals before applying

A refusal prints the reason and affected IDs. Typical cases include:

| Reported problem | What to review in the old configuration |
| - | - |
| Unpublished draft | Publish the intended draft or make it match the published rules. |
| Rules share a priority and can decide differently | Give the conflicting rules an explicit, unambiguous order. |
| Borrowed key or an item that cannot change vault | Reconnect or replace the dependent credential within the intended vault boundary. |
| An unsupported split or a split that changes access | Simplify the affected rules and agent groups without widening access. Rehearse again. |
| A malformed link, key, or missing owner | Fix the reported resource or ownership problem. Don't remove the check. |

Resolve these on 2.x before retrying the upgrade. If you have already deployed 3.0, use the snapshot rollback below to return to that configuration first. Don't edit access rows directly to make the move pass.

**5. Apply the move by hand**

Proceed only after reviewing a clean dry run and accounting for every organization-wide item left unused:

```bash theme={null}
docker compose -p onecli exec -T -w /app api \
  node apps/api-server/dist/vault-move.mjs --apply
```

The move works one organization at a time. A refused organization writes nothing, including its old keys. Other organizations can complete, so a nonzero exit does not mean the whole database rolled back.

Successful key conversion stores a hash and deletes the old plain key row. The key string held by an existing script does not change. The summary must end with no plain keys left, including `plain keys now: 0`. Resolve any reported key row that remains before declaring the upgrade complete.

You can run the move again. It checks the work already recorded rather than copying everything again. Keep reading the unused organization-item count on later runs: those items have not been deleted or made available.

**6. Verify access and upgrade the CLI**

Compare access with the saved before-check:

```bash theme={null}
docker compose -p onecli exec -T -w /app api \
  node apps/api-server/dist/vault-move.mjs --verify \
  --against /dev/stdin < vault-access-before.txt
```

The check exits zero only when access matches and no plain keys remain. Unused organization-wide items cause expected differences: `only before` for an item an agent no longer reaches, and possibly `only after` with no item for an agent left with nothing. Compare those IDs with the move report. Don't ignore any other difference.

Add the needed organization-wide credentials to each appropriate vault again. Review item permissions and test both allowed and denied access with disposable credentials before resuming workloads.

Install the matching published 3.0 CLI using the [CLI installation instructions](/docs/cli/onecli-cli.md). The install script downloads the published CLI release:

```bash theme={null}
curl -fsSL https://onecli.sh/cli/install | sh
```

Create and revoke managing keys at **Settings** > **API keys**. A new key is shown once. If you lost a key, create another and revoke the old one instead of trying to reveal it. Keep older `aoc_` agents on your reconnect list, and review scripts that use retired API calls before resuming them.

## Roll back by restoring the snapshot

There is no data-move undo command. An older image is not a rollback of a migrated database, converted key rows, or new ciphertext.

1. Stop the 3.0 services and keep agents paused. Preserve the failed upgrade's reports separately.
2. Restore the complete pre-upgrade database snapshot into the intended rollback database. Don't merge individual rows from the upgraded copy.
3. Restore the matching gateway data volume, instance secrets, and previous Compose configuration. Point all services at the restored database.
4. Start the exact previous image versions you recorded. Check sign-in, stored credentials, agent access, and gateway trust before allowing traffic.
5. Resolve the dry-run refusals or configuration problem on that restored 2.x installation, then take a new snapshot and rehearse again.

Restoring the snapshot discards changes made after it. That includes keys or agents created during the upgrade. Restoring old agent tokens can also make them usable again. Revoke any compromised upstream credential and disconnect affected agents as part of recovery.

## Next steps

* [Harden the upgraded instance](/docs/self-hosting/hardening.md).
* [Lock down Docker and Linux workloads](/docs/guides/agent-lockdown.md).
* [Understand the 3.0 trust boundary](/docs/guides/trust-model.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.