---
title: Storage backends
description: SQLite and PostgreSQL storage, their files and the data directory, and how to test connections, validate changes and switch backends.
---

Pipedash stores providers, retained run history, metrics and preferences in SQLite or PostgreSQL. `storage.backend` selects the backend. SQLite is the default and keeps the data in a local file. PostgreSQL keeps it in a central database, which suits a deployment shared by a team.

General cache objects use the local filesystem with SQLite and PostgreSQL storage with PostgreSQL. Downloaded run logs remain local files with either backend.

## Backend comparison

| | SQLite | PostgreSQL |
|---|---|---|
| `storage.backend` | `sqlite` | `postgres` |
| Main database | `<data_dir>/pipedash.db` | The database in `storage.postgres.connection_string` |
| General cache objects | `<data_dir>/cache/` | PostgreSQL |
| Downloaded run logs | `<data_dir>/cache/run-logs/` | `<data_dir>/cache/run-logs/` |
| Schema updates | Run when the file opens | Run on connect |
| Tokens | Keyring on desktop and Keychain on iPhone by default, otherwise encrypted in the database | Encrypted in the database |

The [Token storage](/docs/configuration/token-storage) page covers the token row.

## SQLite

The database file is `pipedash.db` inside the data directory. Pipedash creates the directory and file when they are missing.

Metrics live in `pipedash.db`. A separate `metrics.db` is a legacy file. The current startup path does not import its contents.

## PostgreSQL

<Screenshot src="settings-storage" alt="Settings, Storage section with backend, credentials, storage paths, and the Test connection and Configure storage buttons" caption="The Storage section in Settings." />

PostgreSQL needs the backend and the connection string in `config.toml`.

```toml
[storage]
backend = "postgres"

[storage.postgres]
connection_string = "${PIPEDASH_POSTGRES_URL}"
```

An empty connection string with `backend = "postgres"` is a validation error. Pipedash runs the PostgreSQL schema updates when it opens the database, and again in the web setup route.

PostgreSQL support is part of the default build. A build without it rejects the backend with `PostgreSQL feature not enabled`.

PostgreSQL tokens need a vault password. Without one, the token store uses a random password that it does not save, so a restart cannot decrypt earlier tokens. `PIPEDASH_VAULT_PASSWORD` or `storage.vault_password` supplies the password.

## Data directory

Pipedash resolves the data directory in this order:

1. `storage.data_dir` when it is not empty.
2. `PIPEDASH_DATA_DIR`.
3. The platform data directory plus `pipedash`, or `.pipedash` when none exists.

The desktop app uses its app data directory and writes that path into `storage.data_dir` of its starter `config.toml`. A Docker setup sets `PIPEDASH_DATA_DIR` to `/data`. `storage.data_dir` moves the database.

On iPhone the data directory always follows the current app container, because iOS moves the container on each install and update. At startup Pipedash removes a stored absolute `data_dir` from `config.toml` and points `PIPEDASH_DATA_DIR` at the container.

`GET /api/v1/storage/paths` reports the effective locations: `config_file`, `pipedash_db`, `metrics_db`, `data_dir`, `cache_dir` and `vault_path`.

## Target tests and validation

The wizard and config editor validate changes before applying them. These requests do not transfer data.

| Action | Route | Result |
|---|---|---|
| Connection test | `POST /api/v1/storage/test-connection` | Tests the selected config and cache backends |
| Prepare wizard draft | `POST /api/v1/storage/draft` | Returns field errors, password warnings and `needs_migration` |
| Analyze editor content | `POST /api/v1/storage/config/analyze` | Takes `{ "new_content": "<toml>" }` and returns errors, warnings and an optional migration plan |

The Test connection button sends the current storage config. Opening a target can create its schema, so a connection test can change the target database.

The config editor also tests a changed PostgreSQL connection. Its analysis reports the result in `postgres_connection`.

## Backend switching

The Configure storage button in Settings, under Storage, opens the wizard. The wizard handles the backend, the connection string and the data directory. It offers two paths.

- **Transfer data:** the wizard plans the transfer, backs up the old storage, runs the steps and then saves the config.
- **Start fresh:** the wizard tests the target, then saves the config without transferring the current database. Existing target data stays there. Choose an unused location for an empty database. The web server reloads storage after saving. A reload failure returns an error and does not restore the previous config file.

The iPhone app has no Configure storage button.

Start fresh skips the database transfer. It does not remove `[providers]` blocks from `config.toml`. Pipedash applies those blocks when it opens the target storage, so file-configured providers can appear again. Their token references also apply.

An already-configured web server changes storage through this wizard. It uses `POST /api/v1/storage/draft` and `POST /api/v1/storage/apply`, not the first-run setup routes.

A paired client cannot change the storage of the host. Settings shows "Storage is on \<host>". Requests to host-managed storage routes return `409` with code `HOST_MANAGED`.

### What a transfer moves

| Data | Moves with |
|---|---|
| Providers and the metrics settings of each pipeline and the global metrics settings | Always, when the database, the data directory or the token store changes |
| Custom views, their members, pins and hidden pipelines | With the providers. Pipedash remaps the provider ids, and a rule drops a provider that did not move. |
| Tokens | The tokens option |
| Cache entries, retained run history, completed downloaded logs, cached log trees, metric rows and metric processing state | The cache option. Retained history includes archived FluxCD reconciliations. Incomplete downloads and unpublished temporary files stay behind. |
| Paired devices, their notification preferences, push registrations and alerts | With the providers when the source and target use different databases. Pipedash remaps provider and pipeline references. Alerts keep their ids and queue positions, so connected phones continue where they stopped. |

Pipeline ids carry the provider id. Pipedash remaps run history, log documents and metric rows to the target provider ids. Data for providers that did not move stays behind.

When both configs use the same database, Pipedash skips the run-history and metric-row copy. Local logs can still move when the data directory changes. A repeat transfer does not copy a metric run twice. The migration summary shows how many metric entries moved.

Two PostgreSQL connection strings name the same database when they have the same host, port and database name. Without a database name, the user name counts as the database. A connection string that changes only the password or an option keeps the same database, so nothing is copied.

A transfer into a target that already has alerts keeps them. An alert that is already in the target is not copied twice. When a target alert holds the same queue position as a moved one, Pipedash moves the target alert to the queue's end. A phone may show that alert once more. With the [`clean_target`](/docs/configuration/setup-wizard) option, the moved alerts replace the target's alerts.

The [Setup wizard](/docs/configuration/setup-wizard) page covers the steps, the options, the backups and the rollback.

### Editing config.toml

Editing `backend` in `config.toml` outside Pipedash changes only where Pipedash reads, and it copies no data. The Edit button next to the Configuration path in Settings, Storage opens an editor titled "Edit config.toml". The editor parses the TOML and analyzes the change before it saves. A change that needs a transfer opens a "Migration required" dialog with a "Migrate existing data" option and a confirm button. The button reads "Proceed with migration" on desktop and web, and "Migrate" on mobile. The editor saves the content after the migration succeeds.

A new backend, a new data directory or a PostgreSQL connection string that points at another database needs a transfer. Moving from one PostgreSQL database to another with the same data directory copies the providers, tokens and retained history like a backend change.

With the box cleared, the editor still runs the provider step and skips the token and cache steps. The providers arrive in the new storage without tokens.

Saving storage settings in Settings keeps a `${VAR}` reference in `config.toml` while the variable still resolves to the saved value. A PostgreSQL password can use such a reference. A changed value replaces the reference. A rotated secret in the variable still applies.

"Migrate existing data" starts checked. With it checked, the editor transfers tokens, retained run history, archived runs, completed downloaded logs and metrics through the same migration steps as the wizard. The editor accepts `${VAR}` references. It resolves them for analysis and saves the submitted text after a successful migration.
