Merge pull request #2872 from FaySmash/patch-1

Improved the understandability of the postgres upgrade steps
This commit is contained in:
vabene1111 2024-01-19 16:13:28 +08:00 committed by GitHub
commit 0493ef7e3a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -124,13 +124,13 @@ to your dream setup.
## How can I upgrade postgres (major versions)? ## How can I upgrade postgres (major versions)?
Postgres requires manual intervention when updating from one major version to another. The steps are roughly Postgres requires manual intervention when updating from one major version to another. The steps are roughly
1. use `pg_dumpall` to dump your database into SQL (for Docker `docker-compose exec -T <database_container_name> pg_dumpall -U <postgres_user_name> -f /path/to/dump.sql`) 1. use `pg_dumpall` to dump your database into SQL (for Docker `docker-compose exec -T <postgres_container_name> pg_dumpall -U <postgres_user_name> -f /path/to/dump.sql`)
2. stop the DB / down the container 2. stop the DB / down the container
3. move your postgres directory in order to keep it as a backup (e.g. `mv postgres postgres_old`) 3. move your postgres directory in order to keep it as a backup (e.g. `mv postgres postgres_old`)
4. update postgres to the new major version (for Docker just change the version number and pull) 4. update postgres to the new major version (for Docker just change the version number and pull)
5. start the db / up the container (do not start tandoor as it will automatically perform the database migrations which will conflict with loading the dump) 5. start the db / up the container (do not start tandoor as it will automatically perform the database migrations which will conflict with loading the dump)
6. if not using docker, you might need to create the same postgres user you had in the old database 6. if not using docker, you might need to create the same postgres user you had in the old database
7. load the postgres dump (for Docker `'/usr/local/bin/docker-compose exec -T <database_container_name> psql -U <postgres_user_name> postgres < /path/to/dump.sql`) 7. load the postgres dump (for Docker `'/usr/local/bin/docker-compose exec -T <postgres_container_name> psql -U <postgres_user_name> <postgres_database_name> < /path/to/dump.sql`)
If anything fails, go back to the old postgres version and data directory and try again. If anything fails, go back to the old postgres version and data directory and try again.