---
title: "Back up your server"
description: "Back up and restore the database and settings of a self-hosted Vigiora Server on Linux."
url: https://vigiora.com/docs/admin/backups
updated: 2026-11-25T11:37:01.000Z
---

# Back up your server

> Back up and restore the database and settings of a self-hosted Vigiora Server on Linux.

> **Verified procedure**
>
> These commands were tested on the Linux install layout (back up, restore over changed data, and restore onto a fresh install). Still test a restore on a spare machine once, so you know your backups work.

Vigiora Server doesn't make backups of its database by itself yet. This page shows how to back it up by hand with the PostgreSQL tools that come with the server. The steps are for **Linux**.

> **Note**
>
> The installer never deletes data. When you reinstall, upgrade or uninstall, anything it replaces is moved to `/var/backups/vigiora/<date>/` first. That is a safety net, not a backup: it lives on the same disk.

## What to back up

| What | Where (Linux default) | Why |
| --- | --- | --- |
| **Database** | Embedded PostgreSQL in `/var/lib/theia/pg/` | Cameras, users, groups, sites, alert rules, Guardian history, faces, API keys. |
| **Settings file** | `/etc/vigiora.env` | Secrets and site settings. Needed to restore: it holds the keys that unlock data stored in the database. |
| **Configuration** | `/etc/vigiora/` and `/etc/go2rtc/go2rtc.yaml` | Server and video engine configuration. |
| **Recordings** | `/var/lib/theia/recordings/` | Video. Large; back up only if you need to keep it. |

If you installed with `--data-dir`, the database and recordings are under that folder instead of `/var/lib/theia`.

> **Keep backups private**
>
> The settings file and the database contain passwords, secrets and camera credentials. Store backups encrypted, somewhere only admins can read.

## Back up the database

The database runs on the server itself and only listens on `127.0.0.1`, on a port chosen at install time (5433 or higher). The port and the password are in files that only root and the `vigiora` account can read.

1. **Open a terminal on the server**

   Sign in to the server with an account that can use `sudo`.

2. **Make the dump**

   Run:

   ```bash
   sudo sh -c 'umask 077; PGPASSWORD="$(cat /var/lib/theia/pg/.password)" \
     /opt/vigiora/pgsql/bin/pg_dump -h 127.0.0.1 -p "$(cat /var/lib/theia/pg/port)" \
     -U vigiora -d vigiora -Fc -f /root/vigiora-db-$(date +%F).dump'
   ```

   This writes a compressed dump such as `/root/vigiora-db-2026-10-30.dump`, readable only by root. The server keeps running.

3. **Copy the settings**

   Run:

   ```bash
   sudo tar czf /root/vigiora-config-$(date +%F).tar.gz /etc/vigiora.env /etc/vigiora /etc/go2rtc
   ```

   `/etc/vigiora.env` matters: its `VIGIORA_NODE_TOKEN_KEY` unlocks the cloud connection stored in the database, and `JWT_SECRET` keeps people signed in after a restore.

4. **Move both files off the server**

   Copy them to another machine, a NAS or cloud storage.

> **Note**
>
> Use the bundled `pg_dump` in `/opt/vigiora/pgsql/bin`. A system `pg_dump` older than version 16 refuses to dump this database. Recordings aren't in the dump: they're files in `/var/lib/theia/recordings/`.

> **Run it every night**
>
> Put the commands in a script and run it from root's crontab, for example `0 3 * * * /root/vigiora-backup.sh`. Keep several days of dumps and delete old ones.

## Check a backup

List what's inside a dump without restoring it:

```bash
/opt/vigiora/pgsql/bin/pg_restore -l vigiora-db-2026-10-30.dump | head
```

## Restore

Restore onto a server running the **same or a newer** Vigiora version. On start, the server applies any newer database changes by itself.

1. **Stop the server**

   Run `sudo systemctl stop vigiora`. This also stops its database, so the next step starts only the database.

2. **Start the database on its own**

   ```bash
   sudo -u vigiora /opt/vigiora/pgsql/bin/pg_ctl -D /var/lib/theia/pg/data \
     -l /tmp/vigiora-restore-pg.log -w start
   ```

3. **Restore the dump**

   ```bash
   sudo sh -c 'PGPASSWORD="$(cat /var/lib/theia/pg/.password)" \
     /opt/vigiora/pgsql/bin/pg_restore -h 127.0.0.1 -p "$(cat /var/lib/theia/pg/port)" \
     -U vigiora -d vigiora --clean --if-exists --single-transaction /root/vigiora-db-2026-10-30.dump'
   ```

   `--single-transaction` means a failed restore leaves the database exactly as it was.

4. **Stop the database and start the server**

   ```bash
   sudo -u vigiora /opt/vigiora/pgsql/bin/pg_ctl -D /var/lib/theia/pg/data -m fast -w stop
   sudo systemctl start vigiora
   ```

   Sign in and check your cameras, users and rules.

### Restoring onto a new machine

Install Vigiora Server as usual, then follow the same steps. The new install has its own database password and port, which is fine: the dump doesn't contain them. Before the last step, copy `VIGIORA_NODE_TOKEN_KEY` and `JWT_SECRET` from your backed-up `/etc/vigiora.env` into the new `/etc/vigiora.env`. Otherwise you'll need to reconnect the server to Vigiora.

> **Warning**
>
> Test a restore on a spare machine before you need it. If the restored server can't reach Vigiora cloud, reconnect it with **Run setup** under [**Settings** → **Remote access** → **Cloud and remote access**](https://vigiora.com/docs/admin/system#vigiora-cloud).

---

Source: https://vigiora.com/docs/admin/backups · Last updated 25 Nov 2026, 11:37 UTC
