Skip to content

Commit f23c4af

Browse files
add postgres 17 upgrade steps to 2.39.0 upgrade notes (#12585)
* postgres 17 upgrade steps * more info * more info * improvements * improvements * improvements * improvements * improvements
1 parent a33d46d commit f23c4af

File tree

1 file changed

+109
-2
lines changed
  • docs/content/en/open_source/upgrading

1 file changed

+109
-2
lines changed

docs/content/en/open_source/upgrading/2.39.md

Lines changed: 109 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,114 @@
22
title: 'Upgrading to DefectDojo Version 2.39.x'
33
toc_hide: true
44
weight: -20240903
5-
description: No special instructions.
5+
description: Major upgrade of Postgres 16 to 17
66
exclude_search: true
77
---
8-
There are no special instructions for upgrading to 2.39.x. Check the [Release Notes](https://github.com/DefectDojo/django-DefectDojo/releases/tag/2.39.0) for the contents of the release.
8+
9+
# PostgreSQL Major Version Upgrade in Docker Compose
10+
11+
This release incorporates a major upgrade of Postgres. When using the default docker compose setup you'll need to upgrade the Postgres data folder before you can use Defect Dojo 2.39.0.
12+
13+
There are lots of online guides to be found such as https://hub.docker.com/r/tianon/postgres-upgrade or https://github.com/pgautoupgrade/docker-pgautoupgrade.
14+
15+
There's also the [official documentation on `pg_upgrade`](https://www.postgresql.org/docs/current/pgupgrade.html), but this doesn't work out of the box when using Docker containers.
16+
17+
Sometimes it's easier to just perform the upgrade manually, which would look something like the steps below.
18+
It may need some tuning to your specific needs and docker compose setup. The guide is loosely based on https://simplebackups.com/blog/docker-postgres-backup-restore-guide-with-examples.
19+
If you already have a valid backup of the postgres 16 database, you can start at step 4.
20+
21+
---
22+
23+
## 0. Backup
24+
25+
Always back up your data before starting and save it somewhere.
26+
Make sure the backup and restore is tested before continuing the steps below where the docker volume containing the database will be removed.
27+
28+
## 1. Start the Old Postgres Container
29+
30+
If you've acceidentally already updated your docker-compose.yml to the new versions, downgrade to postgres 16 for now:
31+
32+
Edit your `docker-compose.yml` to use the old Postgres version (e.g., `postgres:16.4-alpine`):
33+
34+
```yaml
35+
postgres:
36+
image: postgres:16.4-alpine
37+
...
38+
```
39+
40+
Start only the Postgres container which will now be 16.4:
41+
42+
```bash
43+
docker compose up -d postgres
44+
```
45+
46+
---
47+
48+
## 2. Dump Your Database
49+
50+
```bash
51+
docker compose exec -t postgres pg_dump -U defectdojo -Fc defectdojo -f /tmp/defectdojo.dump
52+
docker cp <postgres_container_name>:/tmp/defectdojo.dump defectdojo.dump
53+
```
54+
You can find the postgres_container_name via `docker container ls` or `docker ps`.
55+
56+
---
57+
58+
## 3. Stop Containers and Remove the Old Volume
59+
60+
You can find the volume name via `docker volume ls`.
61+
62+
```bash
63+
docker compose down
64+
docker volume rm <defectdojo_postgres_volume_name>
65+
```
66+
67+
---
68+
69+
## 4. Switch to the New Postgres Version
70+
71+
Edit your `docker-compose.yml` to use the new version (e.g., `postgres:17.5-alpine`):
72+
73+
```yaml
74+
postgres:
75+
image: postgres:17.5-alpine
76+
...
77+
```
78+
79+
---
80+
81+
## 5. Start the New Postgres Container
82+
83+
```bash
84+
docker compose up -d postgres
85+
```
86+
87+
---
88+
89+
## 6. Restore Your Database
90+
91+
**Copy the dump file into the new container:**
92+
93+
```bash
94+
docker cp defectdojo.dump <postgres_container_name>:/defectdojo.dump
95+
```
96+
97+
**Restore inside the container:**
98+
99+
```bash
100+
docker exec -it <postgres_container_name> bash
101+
pg_restore -U defectdojo -d defectdojo /defectdojo.dump
102+
```
103+
104+
---
105+
106+
## 7. Start the Rest of Your Services
107+
108+
```bash
109+
docker compose up -d
110+
```
111+
112+
---
113+
114+
115+
Check the [Release Notes](https://github.com/DefectDojo/django-DefectDojo/releases/tag/2.39.0) for the contents of the release.

0 commit comments

Comments
 (0)