63 lines
1.6 KiB
Markdown
63 lines
1.6 KiB
Markdown
|
# Manual and Help
|
||
|
|
||
|
## Upgrade Postgrs to newer Version (i.e. 15 to 16)
|
||
|
|
||
|
|
||
|
### 1. Copy Service
|
||
|
|
||
|
1.1 Copy whole service definition in docker-compose.yaml
|
||
|
1.2 Rename old service to *-old
|
||
|
1.3 Move path from new service to i.e postgres16
|
||
|
1.4 Set postgres version explicit to new version
|
||
|
|
||
|
Example:
|
||
|
```
|
||
|
databasedb-old:
|
||
|
image: postgres:${POSTGRES_VERSION}
|
||
|
volumes:
|
||
|
- ${VOLUMES_PATH}/databasedb:/var/lib/postgresql/data
|
||
|
environment:
|
||
|
- POSTGRES_DB=${POSTGRES_DB}
|
||
|
- POSTGRES_USER=${POSTGRES_USER}
|
||
|
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
|
||
|
|
||
|
databasedb:
|
||
|
image: postgres:16
|
||
|
volumes:
|
||
|
- ${VOLUMES_PATH}/databasedb16:/var/lib/postgresql/data
|
||
|
environment:
|
||
|
- POSTGRES_DB=${POSTGRES_DB}
|
||
|
- POSTGRES_USER=${POSTGRES_USER}
|
||
|
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
|
||
|
```
|
||
|
|
||
|
### 2. Move data
|
||
|
Backup data from service one to new servic with the following command:
|
||
|
```
|
||
|
docker exec old-service pg_dumpall -U dbuser | docker exec -i new-service psql -U dbuser -d database
|
||
|
```
|
||
|
|
||
|
### 3. Set password
|
||
|
```
|
||
|
docker exec -i monitoring-databasedb-1 psql -U dbuser -d database -c "ALTER USER \"dbuser\" PASSWORD 'secret';"
|
||
|
```
|
||
|
|
||
|
### 4. Test
|
||
|
```docker compose up -d``` and check if service is correctly running.
|
||
|
|
||
|
### 5. Cleanup
|
||
|
5.1 Remove old service in docker-compose.yaml
|
||
|
5.2 Set explicit version again to ${POSTGRES_VERSION} and adopt .env file
|
||
|
5.4 remove old volume dir
|
||
|
|
||
|
|
||
|
### 6. May be move Data dir
|
||
|
6.1. ```docker compose down```
|
||
|
6.2 ```mv /mnt/dockervolumes/databasedb16 /mnt/dockervolumes/databasedb```
|
||
|
6.3 docker-compose.yaml anpassen
|
||
|
6.1. ```docker compose up -d```
|
||
|
|
||
|
|
||
|
|
||
|
|