mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-23 21:33:19 +00:00
docs(postgres): a backup restores into the same or a newer major only
The restore now refuses a dump from a newer PostgreSQL major, so the guide and the compose file no longer promise restores across every major.
This commit is contained in:
@@ -27,8 +27,8 @@
|
||||
# path). An existing database stays on the major it was created with: when
|
||||
# you update this file, keep your image tag and volume path. Moving to
|
||||
# another major needs pg_upgrade, or a dump and restore (a TREK backup
|
||||
# restored into a new, empty database works across majors), never just a
|
||||
# new image tag.
|
||||
# restored into a new, empty database of the same or a newer major), never
|
||||
# just a new image tag.
|
||||
services:
|
||||
db:
|
||||
image: postgres:18
|
||||
|
||||
@@ -82,7 +82,7 @@ The file uses PostgreSQL 18, the newest version TREK supports, which matches the
|
||||
|
||||
To run 14 to 17, change both the image tag and the volume path in the `db` service. The 18 image refuses a volume at `/var/lib/postgresql/data`, and a 14 to 17 image with its volume one level up would keep the data in an anonymous volume, which `docker compose down` leaves behind, so the next start comes up on an empty database.
|
||||
|
||||
A database stays on the major version it was created with. When you update `docker-compose.postgres.yml`, keep the image tag and the volume path of your existing database. A new image tag on the old volume does not bring the data along: the 18 image refuses a volume that holds an older database, and an older image does not find the data of a newer one. To move a database to another major, use `pg_upgrade`, or dump and restore it: take a backup under **Admin > Backup** and download it, start the new major on a new, empty volume, and restore the backup there, on the first start with `RESTORE_FROM_BACKUP` (see [Backups and restore](#backups-and-restore)) or under **Admin > Backup**. TREK's backups restore across majors.
|
||||
A database stays on the major version it was created with. When you update `docker-compose.postgres.yml`, keep the image tag and the volume path of your existing database. A new image tag on the old volume does not bring the data along: the 18 image refuses a volume that holds an older database, and an older image does not find the data of a newer one. To move a database to another major, use `pg_upgrade`, or dump and restore it: take a backup under **Admin > Backup** and download it, start the new major on a new, empty volume, and restore the backup there, on the first start with `RESTORE_FROM_BACKUP` (see [Backups and restore](#backups-and-restore)) or under **Admin > Backup**. TREK's backups restore into the same or a newer major; TREK refuses a backup from a newer major than the server it restores into.
|
||||
|
||||
### A role that is not a superuser
|
||||
|
||||
@@ -215,7 +215,7 @@ Restoring a backup on Postgres follows these rules:
|
||||
|
||||
- **The current database is replaced.** TREK first keeps a copy of it as `data/pre-restore-<time>.pgdump`. `pg_restore` then turns the archive's dump into a SQL script, and `psql` clears the current schema, which drops its tables, views, sequences, functions, types and collations, and runs the script. Both steps run in one transaction, so a restore that fails leaves the database as it was.
|
||||
- **Plugin data is replaced with the archive's.** The same transaction drops every `trek_plugin_*` schema the role owns and loads the ones the dump holds, so a plugin installed after the backup loses its data, as it does on SQLite. Schemas the role does not own, and every other schema of the database, are never touched.
|
||||
- **TREK checks the archive before it replaces anything.** The archive must hold a Postgres dump, not a SQLite file. The dump must carry TREK's migration history, and it must not come from a newer TREK. TREK refuses the restore with a message saying which check failed.
|
||||
- **TREK checks the archive before it replaces anything.** The archive must hold a Postgres dump, not a SQLite file. The dump must carry TREK's migration history, it must not come from a newer TREK, and it must not come from a newer PostgreSQL major than the server. TREK refuses the restore with a message saying which check failed.
|
||||
- **The client tools must be recent enough.** The restore refuses `pg_restore` or `psql` older than 18.0, 17.6, 16.10, 15.14 or 14.19, and tools older than the server.
|
||||
- **The role must not be a superuser.** The restore refuses a role that is a superuser or a member of one, holds `pg_execute_server_program`, `pg_read_server_files` or `pg_write_server_files`, may run a server file function, was granted ALTER SYSTEM or a superuser-only setting, or on PostgreSQL 14 or 15 has CREATEROLE or is a member of a role that has it. See [A role that is not a superuser](#a-role-that-is-not-a-superuser).
|
||||
- **The restore needs free space in the data directory.** `pg_restore` writes the dump out as a SQL script next to the unpacked archive before `psql` runs it, and the script is several times larger than the dump. It may grow to `BACKUP_MAX_DECOMPRESSED_MB` (5 GB by default); a larger one is stopped, nothing is replaced, and the work files are removed. Raise the limit for a genuine backup that needs more.
|
||||
|
||||
Reference in New Issue
Block a user