# Run and maintain

Update the server and the app, back up the data and read the device alerts.

## Update the server

```sh
cd ~/guardian
docker compose pull
docker compose up -d
```

The server updates the database when it starts. The data stays in `data/`. To go back to a version, set the image tag to `sha-<commit>` in `compose.yaml`.

On Unraid: go to **Docker** > **Check for Updates**, then **apply update**.

## Mac app updates

Kid Macs check your server for a new version every hour and install it by themselves. Your server gets the versions from the Guardian project on GitHub.

## Back up

All data is in `data/`. Copy the database while the server runs:

```sh
docker compose exec guardian python -c "import sqlite3; sqlite3.connect('/data/app.db').backup(sqlite3.connect('/data/backup.db'))"
```

Then copy these files to your backup:

| File | Content |
|---|---|
| `data/backup.db` | Rules, kids and history. |
| `data/vapid_private.pem`, `data/vapid_public.txt` | Push keys. Without them, each parent must turn on notifications again. |
| `.env` | Settings. |

## Restore

1. Stop the server:
   ```sh
   docker compose down
   ```
2. Delete `data/app.db-wal` and `data/app.db-shm` if they exist.
3. Copy `backup.db` to `data/app.db`. Copy back the other files.
4. Start the server:
   ```sh
   docker compose up -d
   ```

## Device status

The web app shows the status of each device on the kid page (**Devices**) and on the **Live** page. A bad status also shows a red dot next to the kid.

| Status | Meaning | Push notification |
|---|---|---|
| Online | The app runs and sends data. | |
| Locked | The screen of the Mac is locked. | |
| Asleep | The Mac sleeps. | |
| Off | The Mac is shut down, or the kid logged out. | |
| App stopped | The app was quit. | "The app was quit. Protection is off." |
| Silent | No contact for 5 minutes: no network, or the app was killed. Also after 24 hours asleep with no contact (no push). | "No contact. Protection may be off." |
| Extension missing | Chrome is open without the extension. | "The Chrome extension is missing or off." |
| Unpaired | The kid unpaired the Mac from the menu. | "The device was unpaired." |
| Waiting to pair | The device has a pairing code, but is not paired. | |
| Removed | You removed the device. | |

When the app starts again after a kill or a crash, the timeline shows "App was force-quit", and you get the push "The app was stopped without a clean exit."

On the kid Mac:

- If the extension is missing, a full-screen message covers Chrome, with one button to open the extension page.
- If the app does not run, the extension blocks each web page with "Guardian is not running".
- Without network, the app uses its last decisions. New pages and apps get a challenge.

To stop the alert notifications, turn off **Settings** > **Notifications** > **Device alerts**.

