> For the complete documentation index, see [llms.txt](https://docs.forestall.io/forestall/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.forestall.io/forestall/introduction/maintenance/postgresql-update.md).

# Updating PostgreSQL

**PostgreSQL 15** is bundled in the installation folder (`PostgreSQL\15`). PostgreSQL publishes security updates within version 15 regularly. Use this page to move the bundled database to the latest PostgreSQL 15 release.

{% hint style="warning" %}
This page covers updates within PostgreSQL 15 only. Upgrading to version 16 or later changes the on-disk data format. Contact Forestall support before attempting it.
{% endhint %}

## 1. Back up

1. Wait until running scans have finished and no scheduled scan is about to start.
2. Run `Backup-All.ps1` from `C:\Forestall\FSProtect\setup-files\scripts\utils\` in an elevated PowerShell session. It stops the `postgresql-x64-15` and `neo4j` services, archives the PostgreSQL data directory, the Neo4j data, the reports and the configuration files to `C:\backups`, then restarts both services.

## 2. Download the files

Download these two files into the same folder on the Forestall server:

* **Update script**: [Upgrade-PostgreSQL.ps1](https://fsprotect.s3.eu-central-1.amazonaws.com/share/Upgrade-PostgreSQL.ps1)
* **PostgreSQL 15 binaries**: open [EDB PostgreSQL binaries](https://www.enterprisedb.com/download-postgresql-binaries) and download the latest **PostgreSQL 15.x** release for **Windows x86-64**. The file is named like `postgresql-15.<minor>-<build>-windows-x64-binaries.zip`.

{% hint style="info" %}
Download the **zip archive of binaries**, not the interactive installer (`.exe`). Keep the original file name: the script reads the target version from it.
{% endhint %}

## 3. Run the update

1. Open PowerShell **as Administrator**.
2. Go to the folder that contains the two files.
3. Run the script and wait for it to finish:

   ```powershell
   .\Upgrade-PostgreSQL.ps1 -ZipPath .\postgresql-15.<minor>-<build>-windows-x64-binaries.zip -InstallRoot C:\Forestall\FSProtect
   ```

{% hint style="info" %}
If the product is installed on another drive (for example `D:\` or `E:\`), set `-InstallRoot` to that folder, such as `D:\Forestall\FSProtect`.
{% endhint %}

The script stops the `postgresql-x64-15` service and renames the current `PostgreSQL\15` folder to a timestamped backup (`PostgreSQL\15_backup_<timestamp>`). It then extracts the new binaries and copies the `data` folder and its permissions back. The PostgreSQL binaries don't include the `pgvector` extension. If the previous installation had it, the script copies it over. Older installations without pgvector are updated the same way. Finally, the script starts the service, updates the PostgreSQL version entries in the registry, and resets IIS.

If extracting or moving the files fails, the script restores the previous installation automatically. If it fails after that point, the backup folder stays in place for manual recovery. Don't delete it until you have verified the update.

## 4. Verify

1. Open the [Health Check](/forestall/health-check.md) page and confirm the **PostgreSQL Database** checks for API and Core show **Running**.
2. Confirm the new version:

   ```powershell
   C:\Forestall\FSProtect\PostgreSQL\15\bin\psql.exe -U postgres -c "SELECT version();"
   ```
3. If an AI provider is configured, ask the AI Assistant a documentation question. If it answers, the `pgvector` extension works.
4. Once everything works, you can delete the `PostgreSQL\15_backup_<timestamp>` folder.
