---
title: Setup wizard
description: The setup wizard's steps and inputs, the setup API, and how a storage migration plans, backs up and rolls back.
---

The setup wizard creates the first `config.toml` and later moves Pipedash to another storage backend or data directory. It opens on first start when no config exists, and from Settings, then Storage, then Configure storage.

## When the wizard appears

On start the UI asks for the setup status. The web server answers `GET /api/v1/setup/status`. The answer decides which screen opens.

| Field | Meaning |
|---|---|
| `config_exists` | `config.toml` exists in the data directory |
| `config_valid` | The file parses and passes validation |
| `validation_errors` | Error text. The UI shows a Configuration Error screen when the file exists but is invalid. |
| `needs_setup` | No `config.toml` and no legacy file. The UI opens the wizard. |
| `needs_migration` | A legacy `storage_config.json` exists without a `config.toml` |

The desktop app writes a starter `config.toml` before the first status request, so desktop normally reports `needs_setup` as false and the wizard opens from Settings. The web server starts in setup mode when no config exists. In setup mode it listens on `127.0.0.1:8080` unless `PIPEDASH_BIND_ADDR` says otherwise. The [Configuration](/docs/configuration) page covers the defaults.

## Steps

The first-run wizard has the title "Welcome to Pipedash". With an existing config it has the title "Storage settings" and adds a Transfer step.

| Step | Shown | Purpose |
|---|---|---|
| Storage | Always | Backend, location and vault password |
| Transfer | Only with an existing config | Transfer data or Start fresh choice |
| Confirm | Always on desktop and web | Summary and save |
| Success | Desktop, web and mobile reconfiguration | Result and next action |

The native iPhone and Android first-run wizard has no Confirm or Success screen. Its Storage screen shows the on-device database and token store. "Get started" applies the setup and opens the app.

For native mobile reconfiguration, the Transfer step appears only when the change needs a transfer.

### Storage inputs

| Input | Shown | Rule |
|---|---|---|
| Database backend | Always on desktop and web | SQLite or PostgreSQL. When reconfiguring existing storage, a note under the control starts with "Current backend:" and the backend name. |
| PostgreSQL connection URL | PostgreSQL | Required. It must parse as a `postgres://` or `postgresql://` URL with a nonempty host. The placeholder is `postgresql://user:password@localhost:5432/pipedash`. An invalid value shows `Enter a valid PostgreSQL connection URL`. |
| Data directory | SQLite | Prefilled with the default data directory |
| Password and Confirm password | Unless `PIPEDASH_VAULT_PASSWORD` has a value | At least 8 characters, and both fields must match |

When `PIPEDASH_VAULT_PASSWORD` has a value, the step shows "Vault password configured via PIPEDASH_VAULT_PASSWORD" in place of the two password fields.

Continue stays disabled until the PostgreSQL URL is valid and the password rule passes. Passwords of 12 or more characters also get orange hints, such as "Consider using 16+ characters", for length, digits, special characters or mixed case. The hints never block the step.

A desktop move from SQLite with the keyring to encrypted storage shows the notice "Credential migration". It says that the credentials leave the keyring, get encrypted in the database, and need a vault password.

<Screenshot src="setup-wizard-storage" variant="dialog" alt="Storage step with SQLite selected" caption="The Storage step with SQLite." />

<Screenshot src="setup-wizard-postgres" variant="dialog" alt="Storage step with PostgreSQL selected and a connection URL" caption="Choosing PostgreSQL asks for the connection URL." />

### iPhone storage

The iPhone wizard shows "On-device storage" and no inputs. The rows read "Database: SQLite" and "Provider tokens: Device Keychain". The step asks for no vault password. The [Mobile](/docs/deployment/mobile) page covers the app.

On Android the wizard looks the same, and the "Provider tokens" row reads "Android Keystore".

### Transfer, confirm and success

The Transfer step offers "Transfer data", marked Recommended, and "Start fresh". It matters when the backend or data directory changes, or when tokens move from the keyring to encrypted storage.

- **Transfer data:** providers, tokens and history move to the new location.
- **Start fresh:** no providers or credentials move from the current storage. Existing data in the target stays there. Choose an unused location for an empty database. Provider blocks in `config.toml` stay and apply to the target.

On desktop and web, Start fresh shows the warning "Switching without transferring data" and changes the main button to "Switch without transferring". On iPhone, the main button of the Transfer step opens a "Skip data transfer?" confirmation with the buttons "Skip data transfer" and "Go back".

<Screenshot src="setup-wizard-transfer" variant="dialog" alt="Transfer step offering Transfer data, marked Recommended, or Start fresh" caption="The Transfer step appears when a configuration already exists." />

The Confirm step lists the database, the data directory, the credentials, the vault password status and the data migration choice. When a password was entered and the environment does not supply one, it also prints a shell-escaped `export PIPEDASH_VAULT_PASSWORD='...'` command with a copy button. The save button reads "Save and transfer" when it will migrate, "Switch without transferring" for Start fresh with a change, and "Save" otherwise.

<Screenshot src="setup-wizard-confirm" variant="dialog" alt="Confirm step with the configuration summary and the Save and transfer button" caption="The Confirm step before the save." />

The Success step is titled "Setup complete". After a migration it lists the Migration summary with the counts of Providers, Tokens, Cache entries and Metrics. A typed password adds a card with the export command that the next run needs. After a migration in the app it shows "Restart now", and on iPhone "Reload now". Otherwise it shows "Get started".

## What Save does

A first setup writes `config.toml`, then loads it, warms up the token store and starts the background tasks. A typed password makes Pipedash set `PIPEDASH_VAULT_PASSWORD` for the session. With SQLite on desktop it uses the keyring token store.

For an existing setup, Save applies the current draft:

1. Pipedash validates the backend, PostgreSQL URL and required password.
2. With Start fresh and a storage change, it tests the target before saving.
3. A required password entered in the wizard becomes `PIPEDASH_VAULT_PASSWORD` for the session.
4. With Transfer data and a change that needs migration, it runs the transfer with `migrate_tokens = true` and `migrate_cache = true`.
5. It saves the config. The web server reloads storage. The desktop app attempts to reopen the core with the saved config.

A failed transfer stops the save and reports its errors. The backup and rollback rules below apply to failed migration steps.

Start fresh skips the database transfer and leaves existing target data in place. It also keeps provider blocks from `config.toml`, which Pipedash applies when it opens the target.

A web storage reload happens after the config save. If that reload fails, the request returns an error without restoring the previous config file.

### Web setup API

The first-run routes are public. The storage routes use the authentication of the configured instance.

| Route | Auth | Behavior |
|---|---|---|
| `GET /api/v1/setup/status` | None | Returns the status fields above |
| `POST /api/v1/setup/draft` | None | Validates a first-run draft |
| `POST /api/v1/setup/apply` | None | Applies a first-run draft and starts services |
| `POST /api/v1/storage/draft` | Required when the server requires authentication | Validates a storage change on a configured instance |
| `POST /api/v1/storage/apply` | Required when the server requires authentication | Applies a storage change and reloads services |

Draft and apply requests take these fields:

| Key | Type | Required | Default | Description |
|---|---|---|---|---|
| `backend` | string | Yes | None | `sqlite` or `postgres`. The draft parser also accepts `postgresql`. |
| `data_dir` | string | Yes | None | Target data directory. The wizard fills in the default directory. |
| `postgres_url` | string | Yes | None | PostgreSQL connection URL. Use an empty string for SQLite. |
| `vault_password` | string | Yes | None | Password entered in the wizard. Use an empty string when no new password is needed. |
| `vault_password_confirm` | string | Yes | None | Confirmation of the entered password |
| `transfer_data` | boolean | Yes | None | Transfers existing data when the change needs migration |

A draft response contains `config`, `errors`, `password_warnings` and `needs_migration`. Errors are keyed by field name.

An apply response contains `saved`, `migration_stats` and `restart_required`. `migration_stats` is `null` when no transfer runs. The web server returns `restart_required = false` after reloading storage.

The first-run draft and apply routes return `409` with `Setup already completed. Cannot re-initialize an already-configured instance.` after setup completes. Configured instances use the storage routes instead.

On desktop and web, a draft needs a matching password of at least 8 characters when `PIPEDASH_VAULT_PASSWORD` is unset. A missing password fails draft validation rather than completing setup in locked mode. The [Token storage](/docs/configuration/token-storage) page covers the vault.

## Migration plan

The config editor receives an optional migration plan from `POST /api/v1/storage/config/analyze`, with body `{ "new_content": "<toml>" }`. The plan contains the source config, the target config, the steps and flags.

| Plan field | Meaning |
|---|---|
| `steps` | Ordered list of steps |
| `migrate_configs` | `true` when the backend changes, the data directory changes, or tokens move from keyring to encrypted storage |
| `migrate_tokens` | `migrate_configs` and the `migrate_tokens` option |
| `migrate_cache` | `migrate_configs` and the `migrate_cache` option |
| `backend_changed`, `data_dir_changed` | Which setting differs |

The steps run in this order: test the target, migrate configs, migrate tokens, migrate cache, test the migration and update the config. The two test steps and the update step always appear. The other three appear when the plan needs them.

The configs step copies providers and their metrics settings. Across databases, it also copies views, paired devices, notification preferences, push registrations and alerts.

The cache step copies cache entries, retained run history, completed downloaded logs, cached log trees, metric rows and pipeline metric processing state. Retained history includes archived FluxCD reconciliations. Pipedash remaps provider and pipeline ids.

Incomplete log downloads and unpublished temporary files do not transfer. When both configs use the same database, run history and metric rows stay in place. Local log files can still move to a new data directory.

### Options

| Option | Default | Effect |
|---|---|---|
| `migrate_tokens` | `false` | Adds the token step |
| `migrate_cache` | `false` | Adds the cache step |
| `token_password` | None | Password for the token blob. `PIPEDASH_VAULT_PASSWORD` wins when both exist. |
| `dry_run` | `false` | Returns success at once and changes nothing |
| `allow_non_empty_target` | `false` | No effect in the current version |
| `clean_target` | `false` | Deletes target providers and tokens that are not in the source, and replaces the target's alerts with the source's, then compares exact counts |
| `keep_backups` | `false` | Keeps the backups after a successful run |
| `max_retries` | `3` | No effect in the current version |

## Backup and rollback

Every real migration creates backups before it changes the target. Backup failure aborts the run with no changes.

```mermaid
flowchart TD
  A["Create backups"] -->|"fails"| X["Abort with no changes"]
  A --> B["Run steps in order"]
  B -->|"a step fails"| R["Restore config, source database and SQLite target"]
  B -->|"all steps pass"| C["Delete backups unless keep_backups"]
```

| Backup | File name |
|---|---|
| Source SQLite database | `pipedash.db.backup-<YYYYMMDD_HHMMSS>` next to the database |
| Config file | `config.toml.backup-<YYYYMMDD_HHMMSS>` next to the config |
| Non-empty target SQLite database | `pipedash_target.db.backup-<YYYYMMDD_HHMMSS>` next to the target database |
| PostgreSQL source | `postgres_backup_<YYYYMMDD_HHMMSS>.json` in the data directory |

Pipedash copies each SQLite database with `VACUUM INTO`, so a backup includes committed data that still sits in the write-ahead log. A PostgreSQL target has no backup.

On a failed step, Pipedash copies the config backup back over the config file. It restores the source SQLite database and the SQLite target from their backups. Each database restore runs in one transaction. A provider that the failed run had already copied into an existing SQLite target disappears again.

A PostgreSQL source is a JSON export that Pipedash does not restore by itself. That file is the input for manual recovery. The result carries recovery text with the backup paths in `errors`. After a success, cleanup deletes the backups and also deletes `*.backup-*` and `*_backup_*.json` files older than 7 days from the data directory.

Token migration matches providers by name. When a provider gets a different id in the target, Pipedash stores its token under the new id. In that case a token whose provider has no match fails the step with a data consistency error.

## Result

The migration result lists `success`, `steps_completed`, `errors`, `duration_ms`, `provider_id_mapping`, `backups` and `stats`. The stats count providers, tokens, cache entries, metrics and permissions migrated, and providers and tokens cleaned.
