|
1 | 1 | --- |
2 | | -title: 'Upgrading to DefectDojo Version 2.51.x' |
| 2 | +title: "Upgrading to DefectDojo Version 2.51.x" |
3 | 3 | toc_hide: true |
4 | 4 | weight: -20250902 |
5 | | -description: Helm chart changes. |
| 5 | +description: Helm chart changes and Postgres major version updates. |
6 | 6 | --- |
7 | 7 |
|
8 | 8 | ## Helm Chart Changes |
@@ -44,6 +44,96 @@ The following Helm chart values have been modified in this release: |
44 | 44 | - **Fixed secret mounting**: Resolved issues with optional secret mounts and references. |
45 | 45 | - **Improved code organization**: Minor Helm chart refactoring to enhance readability and maintainability. |
46 | 46 |
|
| 47 | +## PostgreSQL Major Version Upgrade in Docker Compose |
| 48 | + |
| 49 | +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.51.0. |
| 50 | + |
| 51 | +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. |
| 52 | + |
| 53 | +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. |
| 54 | + |
| 55 | +Sometimes it's easier to just perform the upgrade manually, which would look something like the steps below. |
| 56 | +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. |
| 57 | +If you already have a valid backup of the postgres 16 database, you can start at step 4. |
| 58 | + |
| 59 | +### 0. Backup |
| 60 | + |
| 61 | +Always back up your data before starting and save it somewhere. |
| 62 | +Make sure the backup and restore is tested before continuing the steps below where the docker volume containing the database will be removed. |
| 63 | + |
| 64 | +### 1. Start the Old Postgres Container |
| 65 | + |
| 66 | +If you've acceidentally already updated your docker-compose.yml to the new versions, downgrade to postgres 16 for now: |
| 67 | + |
| 68 | +Edit your `docker-compose.yml` to use the old Postgres version (e.g., `postgres:17.6-alpine`): |
| 69 | + |
| 70 | +```yaml |
| 71 | +postgres: |
| 72 | + image: postgres:17.6-alpine |
| 73 | + ... |
| 74 | +``` |
| 75 | + |
| 76 | +Start only the Postgres container which will now be 17.6: |
| 77 | + |
| 78 | +```bash |
| 79 | +docker compose up -d postgres |
| 80 | +``` |
| 81 | + |
| 82 | +### 2. Dump Your Database |
| 83 | + |
| 84 | +```bash |
| 85 | +docker compose exec -t postgres pg_dump -U defectdojo -Fc defectdojo -f /tmp/defectdojo.dump |
| 86 | +docker cp <postgres_container_name>:/tmp/defectdojo.dump defectdojo.dump |
| 87 | +``` |
| 88 | + |
| 89 | +You can find the postgres_container_name via `docker container ls` or `docker ps`. |
| 90 | + |
| 91 | +### 3. Stop Containers and Remove the Old Volume |
| 92 | + |
| 93 | +You can find the volume name via `docker volume ls`. |
| 94 | + |
| 95 | +```bash |
| 96 | +docker compose down |
| 97 | +docker volume rm <defectdojo_postgres_volume_name> |
| 98 | +``` |
| 99 | + |
| 100 | +### 4. Switch to the New Postgres Version |
| 101 | + |
| 102 | +Edit your `docker-compose.yml` to use the new version (e.g., `postgres:18-alpine`): |
| 103 | + |
| 104 | +```yaml |
| 105 | +postgres: |
| 106 | + image: postgres:18-alpine |
| 107 | + ... |
| 108 | +``` |
| 109 | + |
| 110 | +### 5. Start the New Postgres Container |
| 111 | + |
| 112 | +```bash |
| 113 | +docker compose up -d postgres |
| 114 | +``` |
| 115 | + |
| 116 | +### 6. Restore Your Database |
| 117 | + |
| 118 | +**Copy the dump file into the new container:** |
| 119 | + |
| 120 | +```bash |
| 121 | +docker cp defectdojo.dump <postgres_container_name>:/defectdojo.dump |
| 122 | +``` |
| 123 | + |
| 124 | +**Restore inside the container:** |
| 125 | + |
| 126 | +```bash |
| 127 | +docker exec -it <postgres_container_name> bash |
| 128 | +pg_restore -U defectdojo -d defectdojo /defectdojo.dump |
| 129 | +``` |
| 130 | + |
| 131 | +### 7. Start the Rest of Your Services |
| 132 | + |
| 133 | +```bash |
| 134 | +docker compose up -d |
| 135 | +``` |
| 136 | + |
47 | 137 | --- |
48 | 138 |
|
49 | 139 | There are other instructions for upgrading to 2.51.x. Check the [Release Notes](https://github.com/DefectDojo/django-DefectDojo/releases/tag/2.51.0) for the contents of the release. |
0 commit comments