<!-- Generated from the canonical OpenPost public page. Do not edit this build artifact. -->

Title: Upgrade to v8
Description: Move a v7 instance to OpenPost v8, which runs on PostgreSQL, and keep your SQLite data, secrets and a way back.
Canonical: https://openpo.st/docs/self-hosting/upgrade-to-v8
Source: [https://openpo.st/docs/self-hosting/upgrade-to-v8](https://openpo.st/docs/self-hosting/upgrade-to-v8)

# Upgrade to v8

OpenPost v8 stores its data in PostgreSQL 17 only. The official image includes a PostgreSQL, so a one-container install keeps working with the same `/data` mount, and your v7 SQLite data imports the first time v8 starts.

## What you need

**Before you start:**

- A v7 instance on any release from v7.0.0 on. You do not need to upgrade to v7.45.0, the last v7 release, first.
- The `.env` values you run today, especially `OPENPOST_JWT_SECRET` and `OPENPOST_ENCRYPTION_KEY`
- A [backup](https://openpo.st/docs/self-hosting/maintenance) of `/data`, taken with the container stopped
- Free disk space for a second copy of the database

v8 brings the database up to date itself: on the first start it applies the v7 changes your release had not reached yet, then the v8 ones. This holds for SQLite files and for PostgreSQL databases that v7 created. A database from before v7.0.0 makes v8 explain this and exit without changing anything: start v7.45.0 once against it, wait until it is serving, stop it, then start v8.

## Upgrade

  **Step 1: Stop OpenPost and back up.**

    Run `docker compose stop openpost`, then copy `data` and `.env` somewhere safe. Note the image
    tag you run today.

  **Step 2: Keep your secrets.**

    Keep the same `OPENPOST_JWT_SECRET` and `OPENPOST_ENCRYPTION_KEY`. Changed values make saved
    provider credentials unreadable or sign everyone out. v7 installs already pass them, so do not
    remove them. If they are missing or weak, OpenPost replaces them on the first start; see [weak secrets from v7](#weak-secrets-from-v7).

  **Step 3: Simplify your Compose file.**

    Remove `user: 0:0` and the `OPENPOST_DATABASE_DRIVER` and `OPENPOST_DATABASE_PATH` lines. Keep
    the `/data` mount. `OPENPOST_PUBLIC_URL` and `OPENPOST_MEDIA_URL` can go when they match
    `OPENPOST_APP_URL`.

  **Step 4: Start v8.**

    Set the image to a v8 release tag from [GitHub Releases](https://github.com/getopenpost/openpost/releases), then run `docker compose pull
    openpost` and `docker compose up -d openpost`.

  **Step 5: Verify the import.**

    Follow the logs with `docker compose logs -f openpost`, then check [readiness and your data](#verify-the-import).

## What the import does

On first start, when the PostgreSQL database is empty and a SQLite file exists, OpenPost:

1. Checks that its encryption key decrypts a sample of every kind of secret stored in the SQLite file. A weak key that decrypts is fine; OpenPost replaces it after the import (see [weak secrets](#weak-secrets-from-v7)).
2. Copies a backup of the SQLite file to `openpost.db.pre-v8-backup` next to it.
3. Creates the schema and copies every table in one transaction.
4. Verifies the row count of every table against the SQLite file.
5. Renames the SQLite file to `openpost.db.migrated-to-postgres` only after it succeeds.

If anything fails, OpenPost rolls back and leaves the SQLite file untouched. The source defaults to `/data/db/openpost.db`. Set `OPENPOST_DATABASE_PATH` only when your v7 file lives elsewhere.

## Weak secrets from v7

v7 started without `OPENPOST_JWT_SECRET` or `OPENPOST_ENCRYPTION_KEY`, or with a value copied from a template or install guide, and then protected nothing: anyone could sign in as any account and read the stored provider tokens. v8 treats a secret as weak when it is unset, shorter than 32 characters, or a published example such as `change-this-...`, `REPLACE-WITH-...` or a value from a community guide, and fixes it on the first start:

- **Encryption key.** OpenPost decrypts a sample of every kind of stored secret with the weak key. When that works, it generates a new key, stores it in `/data/secrets/instance.json`, re-encrypts every stored secret in one transaction and records the new key. The log shows a `WARNING` that says how many values it re-encrypted. If any sample does not decrypt, OpenPost changes no secret and refuses to start; set `OPENPOST_ENCRYPTION_KEY` to the key that encrypted the data and start again. On a first v8 start this check reads the SQLite file before the import, so a refused start imports nothing and leaves `openpost.db` in place for v7 or the next attempt.
- **JWT secret.** OpenPost generates a new secret, stores it in the same file and signs out every session once. Everyone signs in again with their password. Email verification and email change links sent before the upgrade stop working.

After the replacement the file wins over the weak value, so the next starts keep working while the old value is still in your Compose file or `.env`. Each start logs a warning until you remove it. Then back up `/data/secrets/instance.json` with your data: it now holds the only copy of the key. Instance backups made before the replacement carry the old key and are refused on restore, so make a new backup. Rolling back to v7 after the replacement leaves saved provider connections unreadable in v7.

## Verify the import

- `curl -fsS http://localhost:8080/api/v1/ready` returns `"status":"ready"` and `"database":"ok"`.
- `/data/db/openpost.db.migrated-to-postgres` exists and the original `openpost.db` is gone.
- You can sign in, a scheduled post is still scheduled, and a post with media shows its files.
- Connected accounts show no reconnect prompt, which confirms the encryption key is unchanged.

## Roll back

The renamed file is a complete v7 database, so going back is safe while v8 has not become your only copy of new work.

  **Step 6: Stop OpenPost.**
Run `docker compose stop openpost`.
  **Step 7: Restore the v7 file.**

    Rename `data/db/openpost.db.migrated-to-postgres` back to `data/db/openpost.db`, or restore your
    backup of `data`.

  **Step 8: Pin v7 and start.**

    Set the image to the v7 tag you noted, or `ghcr.io/getopenpost/openpost:v7.45.0`, and run
    `docker compose up -d openpost`. Anything you created in v8 is not in the SQLite file. Posts
    that came due while v8 ran are still scheduled in the file, and v7 publishes them again as soon
    as it starts, even when v8 already published them.

If the import failed or v8 refused to start before it, for example because the encryption key did not decrypt the SQLite data, the SQLite file is untouched. Pin your v7 tag until you know why, and keep the logs. If v8 stopped after a completed import, the file was already renamed: rename it back as above before you start v7, or v7 starts with an empty database.

## The `latest` tag

`latest` moves to v8 when it is released. A copied Compose file with only `/data` mounted keeps working, because the container imports your SQLite data and runs its own PostgreSQL. Pin a version tag if you want to choose when the upgrade happens, and record the tag with your backups.

## Use an external PostgreSQL instead

To import into your own PostgreSQL, create an empty PostgreSQL 17 database as described in [use your own PostgreSQL](https://openpo.st/docs/self-hosting#use-your-own-postgresql), set `OPENPOST_DATABASE_URL` and keep the SQLite file mounted at its v7 path. The same automatic import runs. You can also run it by hand, with `--dry-run` to check first:

```sh
openpost db import-sqlite --from /data/db/openpost.db --to "$OPENPOST_DATABASE_URL" --dry-run
openpost db import-sqlite --from /data/db/openpost.db --to "$OPENPOST_DATABASE_URL"
```

A v7 backup ZIP restores into v8 through the same importer, from **Settings → Advanced → Instance**.

## What's next

  - [Back up and restore](https://openpo.st/docs/self-hosting/maintenance): Instance backups, pg_dump and restore.
  - [Troubleshoot an instance](https://openpo.st/docs/self-hosting/maintenance#troubleshoot): Startup, database and sign-in problems.
  - [Database settings](https://openpo.st/docs/self-hosting/configuration#storage): The connection URL and storage variables.
