# Update and upgrade your database

> Install bug and security releases with one click, and upgrade to a new major version after a rehearsal, with undo.

Source: https://rowsafe.sh/docs/guides/updates

Rowsafe updates your database and its server when someone clicks and confirms (or turned on automatic minor updates), with a [Mark](https://rowsafe.sh/docs/concepts/restore-points) first. This page uses PostgreSQL; see [MySQL, MariaDB, MongoDB and ClickHouse](#mysql-mariadb-mongodb-and-clickhouse) and [Redis and Valkey](#redis-and-valkey) for what differs.

| What                                                          | How long PostgreSQL stops                     | Undo                                                                  |
| ------------------------------------------------------------- | --------------------------------------------- | --------------------------------------------------------------------- |
| **Minor update**, e.g. 16.9 to 16.10: bug and security fixes  | A few seconds (a restart)                     | Minor releases don't change behavior; restore to the Mark if you must |
| **Security updates** of the server (OpenSSL, the kernel, ...) | Not at all; some need a reboot                | Not needed                                                            |
| **Reboot**                                                    | A minute or two                               | Not needed                                                            |
| **Major upgrade**, e.g. 16 to 18                              | Measured by the rehearsal: seconds to minutes | 7 days, see [Safe and Fast](#safe-or-fast)                            |

> **Rowsafe Cloud servers:** On [Rowsafe Cloud](https://rowsafe.sh/docs/guides/rowsafe-cloud), security updates install by themselves (no database restart, no reboot), and updates that need a restart run in your weekly [maintenance window](https://rowsafe.sh/docs/guides/rowsafe-cloud#updates-and-maintenance). The buttons still work any time.

## Allow it on the server

Root decides at install:

| Question                                                                     | Name                                             |
| ---------------------------------------------------------------------------- | ------------------------------------------------ |
| `Install PostgreSQL updates and upgrades, when someone clicks Update? [Y/n]` | `updates`                                        |
| `Install this server's security updates, when someone clicks Install? [y/N]` | `security-updates`                               |
| `Reboot this server, when someone clicks Reboot? [y/N]`                      | `reboot` (asked after a yes to security updates) |

Updates need restarts allowed too. To change it later:

```sh
sudo rowsafe-allow restart updates        # allow PostgreSQL updates (and restarts)
sudo rowsafe-allow --remove reboot        # stop allowing reboots
```

See [permissions](https://rowsafe.sh/docs/guides/permissions). The **Updates** tab shows what's allowed.

## Minor updates

When a new release is out, [Pulse](https://rowsafe.sh/docs/guides/monitoring) and the **Updates** tab show **Update to 16.10**. Rowsafe saves a Mark, installs only your major's packages, restarts PostgreSQL, updates pgvector, PostGIS or TimescaleDB in each database if needed, and checks backups still work. For example: "Updated PostgreSQL from 16.9 to 16.10 in 12 s; it didn't accept connections for 3 s."

**Install minor updates automatically** (on the **Updates** tab) updates on Sundays at 03:00 your time, with a Mark first.

> **Warning:** Updating PostgreSQL 16 also updates the server's other PostgreSQL 16 clusters, usually restarting them. The confirmation lists them.

**With the CLI**

```sh
rowsafe update app              # shows the versions, asks you to type the name, updates
rowsafe update app --auto on --timezone Europe/Berlin
```

## Security updates and reboots

Pulse shows **12 security updates are waiting; a reboot is needed**.

- **Install security updates** installs only your distribution's security upgrades. Database packages are left to **Update**. Nothing restarts; a new kernel needs a reboot.
- **Reboot the server** saves a Mark, then reboots (a minute or two). Type the server's name to confirm.

### MySQL, MariaDB, MongoDB and ClickHouse

**Update** works the same: a Mark, then the newest release of your series from the server's own package sources. Automatic Sunday updates work.

**Major upgrades** (MySQL 8.0 to 8.4, MariaDB 10.11 to 11.4, MongoDB 7.0 to 8.0, ClickHouse 25.3 to 25.8) use the same three steps, in Safe mode:

1. **Check** lists newer versions in the server's package sources (add the vendor's repository first) and what blocks the upgrade. MongoDB goes one major at a time. MySQL 8.4 warns about `mysql_native_password` accounts.
2. **Rehearse** starts the new version on a private copy of your latest backup. Nothing on the server changes.
3. **Upgrade** saves a Mark, keeps your packages and a copy of the data, then installs the new version. If it fails, the old one is put back.

**Undo** (7 days) puts the old version back; later writes are kept aside. It needs free disk about the data's size. In Docker, pull the new image and recreate the container.

### Redis and Valkey

**Update** works the same on Debian or Ubuntu, at the newest release of your series. Apps are disconnected for a few seconds. Automatic Sunday updates work.

- **Snapshots must be on**, or the restart would empty the server. Pulse offers **Turn on snapshots** first.
- **Distribution fixes** that keep the version number (Debian 12 stays 7.0.15) show as **A security update of Redis 7.0.15 is available**.
- **October 2025 security releases** (Redis 8.2.2, 8.0.4, 7.4.6, 7.2.11, 6.2.20; Valkey 8.1.4, 8.0.6, 7.2.11) fix CVE-2025-49844, a Lua flaw that lets anyone who can sign in take over the server. Pulse marks them critical.
- **No Mark** on a server with scheduled snapshots only. The confirmation says so.
- **Major upgrades** (Redis 7.2 to 7.4 or 8.x, Valkey 8.1 to 9.0) follow the [steps below](#major-upgrades), with **Undo** for 7 days. Redis 8 has other licenses (RSALv2, SSPLv1 or AGPLv3); the check says so.
- **In Docker**, Pulse shows when your image is old, with the step:

```sh
docker compose pull redis && docker compose up -d redis
```

Change a pinned tag (`redis:8.2.1`) to the series (`redis:8.2`) first.

## Major upgrades

On the **Updates** tab, three steps. On a [server on its own](https://rowsafe.sh/docs/guides/no-account-server#upgrade-postgresql), the same with `sudo rowsafe upgrade` there.

### 1. Check

**Check** changes nothing. It checks the new major and your extension packages are available, [TimescaleDB](#timescaledb) can move, there's free disk, pgBackRest is new enough (2.53 for 17, 2.55 for 18), and lists replicas that will need setting up again.

### 2. Rehearse

**Rehearse** is required. Rowsafe upgrades a private copy of the latest backup (like [Proof](https://rowsafe.sh/docs/concepts/restore-drills)), checks every database opens, then deletes it. Your database isn't touched.

The report shows the **expected downtime** in each mode. A pass allows the upgrade for 14 days. It needs free disk of about 1.3 × the database + 1 GiB (twice that to measure Safe mode).

```sh
rowsafe upgrade app --to 18 --rehearse-only
```

### 3. Upgrade

**Upgrade** asks for the mode and the name. Rowsafe saves a Mark, upgrades with `pg_upgradecluster` (same port, same configuration), moves backups to 18, takes a full backup and runs Proof. If anything fails before 18 accepts connections, 16 is put back.

```sh
rowsafe upgrade app --to 18 --mode safe
```

### Safe or Fast

|              | Safe                                                                     | Fast                                                                             |
| ------------ | ------------------------------------------------------------------------ | -------------------------------------------------------------------------------- |
| How          | Copies the data files (or clones them, where the filesystem supports it) | Hard-links them                                                                  |
| Downtime     | Grows with the database's size, unless cloned                            | Minutes at most, whatever the size                                               |
| Free disk    | About the database's size                                                | Little                                                                           |
| Undo         | Switches back to PostgreSQL 16, which is kept stopped: seconds           | Restores PostgreSQL 16 from the backup at the Mark saved just before the upgrade |
| Lost by undo | Nothing is deleted: what was written to 18 stays in 18, kept aside       | What was written after the upgrade is gone from the live database                |

Rowsafe recommends Safe when there's disk for it.

### Undo, and remove the old version

For 7 days, click **Undo upgrade** on the **Updates** tab (see [Safe or Fast](#safe-or-fast) for what's lost). A Mark is saved first, so writes to 18 stay recoverable.

**Remove PostgreSQL 16** in Pulse frees the disk. Rowsafe removes it by itself after 7 days.

```sh
rowsafe upgrade undo app
rowsafe upgrade cleanup app
```

### TimescaleDB

TimescaleDB must be the **same version** before and after. Check says what to do:

- **TimescaleDB moves to PostgreSQL 18**: same version, nothing to do.
- **Update TimescaleDB first**: click it and type the name (a Mark first; time-series tables lock briefly), then check and rehearse again.
- **Update PostgreSQL first**: install the minor update, which brings the right version, then rehearse again.
- **TimescaleDB can't move yet**: the old major's package is older than the new one's. Upgrade to a major with your version, or dump and restore into a new server. **PostgreSQL 15 to 16 is like this today.**
- **TimescaleDB isn't available** for the new major yet, or yours is newer than its package: wait for the PostgreSQL project to publish it.

## Limits

- **Debian and Ubuntu, PostgreSQL from packages** (a cluster `pg_lsclusters` lists). Elsewhere, only Check and Rehearse.
- **Docker.** Rowsafe can't change your image. Check shows the steps. For minor updates, pull the newest image and recreate the container.
- **Extensions** must be packaged for the new major.
- **TimescaleDB**: PostgreSQL 15 to 16 with TimescaleDB isn't possible yet. See [TimescaleDB](#timescaledb).
- **Replicas** streaming from the server must be set up again.
- **Tablespaces** are upgraded, but not in Fast mode.
- **Rewinding to before the upgrade** needs the old major's programs: keep the old version until you're sure.
- **Automatic updates** are minor releases only, never majors or the server's security updates.

## How it works

The agent runs as `postgres` and can't install anything. A small root helper accepts only a fixed list of requests, checks each against what root allowed (`/etc/rowsafe/updates-allowed`), and builds package names itself: it never runs a command it was sent. See the [security model](https://rowsafe.sh/docs/security).

**Do it yourself: upgrade by hand**

The same steps Rowsafe runs, on the server, as root. Take a Mark and wait for a backup first.

```sh
sudo apt-get install postgresql-18 postgresql-client-18    # plus postgresql-18-<extension> for each extension
sudo pg_dropcluster --stop 18 main                          # the empty cluster the package created
sudo pg_upgradecluster -v 18 -m upgrade 16 main             # --link for Fast mode
sudo -u postgres pgbackrest --config=/etc/rowsafe/pgbackrest/app.conf --stanza=app \
  --pg1-path=/var/lib/postgresql/18/main stanza-upgrade
rowsafe verify app && rowsafe backup app                  # from your workstation
```
