GPROXY_MASTER_KEY; there is nothing to export and no password to reset.
What changes
The database schema is replaced. v4 reads the v3 tables and writes v4 tables in their place before it serves any traffic. What happens to each kind of data:- Providers and credentials: known channel names and their configuration are translated, and secrets are re-sealed under the configured master key.
- Routes and members: a route’s public model name becomes the route name. Each additional name becomes a separate route with a copy of the members.
- Users, passwords, API keys, organizations and teams: carried over. Password hashes (Argon2) and API key digests are preserved, so existing usernames, passwords and keys keep working.
- Prices and budgets: converted to v4’s units. v4 stores amounts to 9 decimal places; a value with more digits is rounded half to even and the change is listed in the report.
- Permissions, rate limits and rewrite rules: supported forms are migrated. Changed meanings and forms that cannot be mapped are listed in the report.
- Team and organization permissions: expanded into one user rule per imported member, disabled users included. The rules reflect membership at the time of the upgrade and do not follow later membership changes. A group with no imported members is reported as skipped. Instances upgraded by a release that did not yet expand these permissions lost them, and a later release does not restore them.
- Usage history: imported in bounded batches with the original token counts, attribution and settled costs. Nothing is repriced and no quota is settled again. v3 fields without a v4 column are kept in
metrics.v3. - Captures, request logs, sessions and audit history: not converted. They remain in the v3 backup. Everyone has to sign in to the console again.
--persistence db and a sqlite:// DSN. The Docker image has the same layout as v3 (data in /app/data, user 65532:65532), but v3 image tags run v3; switch to a v4 tag.
Before you start
- Find where your
GPROXY_MASTER_KEYis set (a.envfile, the service unit, the container environment) and keep a copy. v4 needs the same key to open the credentials; with a different key the upgrade stops before changing anything. - Keep a copy of the v3 executable or note the v3 image tag. You need it to roll back.
- Plan to stop every v3 instance. Only one process may write to the database during the upgrade. If you run v3 and v4 side by side on separate databases, do not give them the same OAuth credentials: each refreshes the tokens and invalidates the other’s.
- For PostgreSQL or MySQL on the CLI, make sure your v4 build includes the driver for that database.
- SQLite
- PostgreSQL
- MySQL
Copy the whole data directory. It holds v4 also writes its own backup next to the database during the upgrade (see below), so leave free space for two more copies of the database: the backup and the converted copy.
gproxy.db and, if present, gproxy.db-wal and gproxy.db-shm; the WAL file can hold committed data that is not yet in gproxy.db, so copy all three together.Upgrading
- Stop all v3 instances.
- Install the v4 executable in place of v3, or change the container image to a v4 tag.
- Start v4 with the same data directory or connection string and the same
GPROXY_MASTER_KEY. You can also run the conversion as its own step withgproxy migrate, which takes the same path and exits. - Watch the log. On SQLite you should see
migrating v3 database to v4, amigratedline per table,v3 import completewith row, dropped and warning counts, and finallyv3 migration completewith the path of the backup. Anything that changed meaning is printed underChanged on the way in, and rows with no v4 form are printed underNOT migrated. - When the log shows the server listening, sign in to the console.
How the conversion works
SQLite
Before it opens the HTTP port, v4 takes a consistent snapshot of the v3 database withVACUUM INTO, which includes committed WAL contents, and keeps it beside the database as gproxy.db.v3-*.bak. It converts that snapshot into a new database in a temporary directory beside the original, decrypting credentials with the existing master key. Only when the import has succeeded does it rename the new database over the original path.
If the conversion fails, the original file is left as it was: fix the cause the log names (for example, restore the original master key) and start again. If the process is interrupted before the rename, the path still holds the v3 database and the next start tries again. After the rename, the path holds a v4 database whose migration ledger marks it as current, and later starts are ordinary v4 starts. Nothing is imported twice.
PostgreSQL and MySQL
v4 first reads the v3 data and checks it, including that the master key opens the credentials. Only then does it rename every v3 table togproxy_v3_<original name> and create the v4 tables under the original names. Configuration, identity and usage history are converted from the renamed tables, and the instance opens to traffic only after the last step.
Progress is kept in the table gproxy_v3_upgrade. Its report_json column holds the skipped rows and the warnings about changed meaning. Identity and usage are written in batches with a checkpoint after each, so an interrupted upgrade resumes where it stopped on the next start.
Each backend keeps a second process out in its own way:
- PostgreSQL holds a session advisory lock for the whole upgrade and renames the v3 tables in one transaction.
- MySQL holds a session lock (
GET_LOCK) across DDL statements, which commit implicitly, and renames all v3 tables in oneRENAME TABLEstatement.
another instance is migrating this database; retry after it finishes.
After a failure, the v3 data is still in the archive tables and the v4 tables may already hold part of the import. Fix the reported error and restart; the upgrade continues. Do not delete gproxy_v3_upgrade or rename the archive tables while the upgrade is incomplete.
Verifying the upgrade
- Read the conversion report: on SQLite in the startup log, on the other backends in
gproxy_v3_upgrade.report_json. Check the skipped providers and the permission changes in particular. - Run
gproxy migrate --status. It lists each schema migration of this build and whether the database has it. It only reads; it never performs the v3 conversion. - In the console, check that providers, credentials, routes, users and API keys are present, and that usage history shows the old totals.
- Send a request through an existing API key, as in Your first request.
gproxy.db.v3-*.bak (SQLite) or drop the gproxy_v3_<name> archive tables (other backends). Keep gproxy_v3_upgrade if you want to keep the report. From here on, v4 schema changes are recorded in SeaORM’s seaql_migrations table.
Rolling back
v3 cannot read a v4 database, and a partially converted database is neither. Rolling back always means restoring the v3 data. Anything written after the upgrade (new usage, configuration changes) is lost.- SQLite
- PostgreSQL and MySQL
- Stop v4.
- Move
gproxy.dband anygproxy.db-walandgproxy.db-shmaside. - Copy
gproxy.db.v3-*.bak(orgproxy.dbfrom your own backup) togproxy.db. - Reinstall the v3 executable or image tag and start it with the original settings and master key.
Importing into a separate instance
The upgrade above converts a database in place. To bring a v3 database or export into a different v4 instance instead, useimport --from-v3:
--source-master-key or GPROXY_IMPORT_SOURCE_MASTER_KEY. --skip-unmappable-providers leaves out providers that cannot be translated, as the automatic upgrade does; without it, such a provider stops the import.
The input can also be the JSON document from v3’s POST /admin/api/export, taken with {"include_secrets": true}. Such an export lacks password hashes, permissions, rate limits and provider models, which a SQLite database carries. When importing an export without hashes, set a console password with --admin-password; a SQLite import does not need it.