homeserver/doc/manual.md

80 lines
1.8 KiB
Markdown
Raw Normal View History

2024-05-17 09:09:46 +02:00
# Manual and Help
## Upgrade Postgrs to newer Version (i.e. 15 to 16)
2024-10-07 15:09:09 +02:00
[Source](https://helgeklein.com/blog/upgrading-postgresql-in-docker-container/)
2024-05-17 09:09:46 +02:00
2024-10-07 15:09:09 +02:00
### 1. Stopp application conatiner
```
docker compose down APP_CONTAINER_NAME
```
2024-05-17 09:09:46 +02:00
2024-10-07 15:09:09 +02:00
### 2. Create a Full DB Dump
Look up the name of your PostgreSQL user in your Docker configuration. Sometimes postgres or something
2024-05-17 09:09:46 +02:00
```
2024-10-07 15:09:09 +02:00
docker exec -it POSTGRESQL_CONTAINER_NAME pg_dumpall -U postgres > dump.sql
```
2024-05-17 09:09:46 +02:00
2024-10-07 15:09:09 +02:00
### 3. Stop the PostgreSQL Container
```
docker stop POSTGRESQL_CONTAINER_NAME # with compose
docker compose stop POSTGRESQL_SERVICE_NAME # with compose
docker compose down # all
2024-05-17 09:09:46 +02:00
```
2024-10-07 15:09:09 +02:00
### 4. Move the DB Data Directory
Use root priveleges to move data dir. Backup old one.
2024-05-17 09:09:46 +02:00
```
2024-10-07 15:09:09 +02:00
mv db/ db-old/
mkdir db
2024-05-17 09:09:46 +02:00
```
2024-10-07 15:09:09 +02:00
### 5. Increment the PostgreSQL Version
Edit the Docker compose file, incrementing the image version.
If image is set with postgres:${POSTGRES_VERSION} change .env file.
### 6. Start container with empty data directory
Start container and Verify logs
2024-05-17 09:09:46 +02:00
```
2024-10-07 15:09:09 +02:00
docker compose up -d POSTGRESQL_CONTAINER_NAME
docker compose logs -f
2024-05-17 09:09:46 +02:00
```
2024-10-07 15:09:09 +02:00
### 7. Import DB Dump
Backup data from service one to new servic with the following command
Use this:
```
docker compose exec -T POSTGRESQL_SERVICE_NAME psql -U POSTGRES_USER POSTGRES_DB < dump.sql
```
### 8. set password
```
docker exec -i POSTGRESQL_CONTAINER_NAME psql -U POSTGRES_USER -d database -c "ALTER USER \"POSTGRES_USER\" PASSWORD 'POSTGRES_PASSWORD';"
```
### 8. Start the Application Container
```
docker compose up -d APP_CONTAINER_NAME
```
### 9. Test
Check if service is working correctly.
Check logs:
```
docker compose logs -f
```
### 10. Clean Up
* Delete the backup directory: rm -rf db-old/
* Delete the dump file: rm dump.sql
* Delete the old PostgreSQL image: docker image prune -a
2024-05-17 09:09:46 +02:00