Skip to content

Commit b273a5f

Browse files
authored
Extended migration steps for PostgreSQL data (#14561)
Extended migration steps for PostgreSQL data after upgrading to 2.55.4.
1 parent 8612ad6 commit b273a5f

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

  • docs/content/releases/os_upgrading

docs/content/releases/os_upgrading/2.51.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,46 @@ _Note: If you are using a bound volume, the path has changed for Postgres18. It
8484
> This has been fixed in 2.55.4 by explicitly setting `PGDATA: /var/lib/postgresql/data` in `docker-compose.yml`.
8585
>
8686
> If you customise the postgres service in your own `docker-compose.override.yml`, make sure `PGDATA` is set to the path where your volume is mounted.
87+
>
88+
> **Important for existing installations**
89+
>
90+
> If you previously ran DefectDojo with PostgreSQL 18 using the old default `docker‑compose.yml`, your PostgreSQL data may be stored inside a nested directory such as `/var/lib/postgresql/data/18/docker`
91+
> In that case, the root of the volume (`/var/lib/postgresql/data`) is non‑empty but is *not* itself a valid Postgres cluster root. After applying the fix that sets `PGDATA: /var/lib/postgresql/data` PostgreSQL may fail to start with an error like `initdb: error: directory "/var/lib/postgresql/data" exists but is not empty` because the existing cluster files still live under the nested versioned path.
92+
>
93+
> To fix this problem you can migrate the existing cluster files into the volume root:
94+
>
95+
> 1. **Stop the Postgres service**
96+
> ```sh
97+
> docker compose stop postgres
98+
> ```
99+
>
100+
> 2. **Verify where your cluster currently lives**
101+
> ```sh
102+
> docker run --rm -it -v <your_volume_name>:/data alpine sh
103+
> ls -la /data
104+
> ```
105+
> Look for a directory such as `18/docker` that contains `PG_VERSION`, `base/`, etc.
106+
>
107+
> 3. **Move the cluster files into the volume root**
108+
> ```sh
109+
> docker run --rm \
110+
> -v <your_volume_name>:/data alpine \
111+
> sh -c "mv /data/18/docker/* /data/"
112+
> ```
113+
>
114+
> 4. **Clean up empty folders (optional)**
115+
> ```sh
116+
> docker run --rm \
117+
> -v <your_volume_name>:/data alpine \
118+
> sh -c "rm -rf /data/18 /data/data"
119+
> ```
120+
>
121+
> 5. **Start Postgres again**
122+
> ```sh
123+
> docker compose up -d postgres
124+
> ```
125+
>
126+
> After this, the database should start using `PGDATA: /var/lib/postgresql/data`, and your existing data will be preserved.
87127
88128
### 0. Backup
89129

0 commit comments

Comments
 (0)