# Maintain your installation

Check health, upgrade coordinated services and protect persistent data.

Canonical page: https://ontlgy.io/docs/operate/maintenance/

Run these commands from the installation directory (`ontlgy-deployments/docker-compose` for Compose). Keep a record of the deployed image tag and protect `.env`.

## Check health

```bash
docker compose ps
curl --fail http://localhost:8080/health
docker compose logs --tail 100 app worker
```

Use your actual port. On Kubernetes, use `kubectl -n ontlgy get pods` and `kubectl -n ontlgy logs deploy/ontlgy-app` and `deploy/ontlgy-worker` instead. A healthy HTTP endpoint is only one signal: verify repository indexing and a real agent query after changes. Document synchronization and enrichment also need the worker.

## Back up before upgrading

The Compose stack uses `postgres-data`, `neo4j-data` and `clones` volumes. Docker prefixes them with the project name. On Kubernetes they are the persistent volume claims of the `ontlgy-postgresql` and `ontlgy-neo4j` StatefulSets and the `ontlgy-clones` claim, and the credentials live in the `ontlgy-secrets` Secret (Helm: the release's Secret).

Protect the control database, graph database and installation secrets as a coordinated backup. Clones can be fetched again, but a graph backup alone does not recover users, source selections or credentials.

For a simple volume-level backup, schedule downtime, stop all four services cleanly, and snapshot/archive their persistent volumes plus the protected configuration using your host's backup tooling. Avoid copying live database files as if they were a consistent backup. Database-native backup methods are also possible when operated according to their respective requirements.

Rehearse restoration on an isolated installation with matching application/database versions and the matching encryption key. Verify sign-in, selected sources, indexed repositories and an agent query before treating a backup as usable.

## Upgrade the app and worker together

Upgrades move to a newer published image tag. The deployment files in [`ontlgy-deployments`](https://github.com/ontlgy/ontlgy-deployments) pin the tag they were validated against, so updating that checkout selects the new version. Review the release's migration notes and take a backup first.

```bash
cd ontlgy-deployments
git pull --ff-only
cd docker-compose
docker compose pull app worker
docker compose stop app worker
docker compose up -d app worker
docker compose ps
```

To run a specific tag instead, set `ONTLGY_IMAGE_TAG` in `.env` (for example `sha-96500e6`) before `docker compose pull`. On Kubernetes, stop the worker first, upgrade, then confirm it is running again:

```bash
kubectl -n ontlgy scale deploy/ontlgy-worker --replicas=0
helm upgrade ontlgy helm/ontlgy --namespace ontlgy -f my-values.yaml   # or: kubectl apply -k kubernetes
kubectl -n ontlgy rollout status deploy/ontlgy-app
kubectl -n ontlgy scale deploy/ontlgy-worker --replicas=1
kubectl -n ontlgy get pods
```

Repeat the values you installed with Helm; keep them in a values file.

The app applies migrations at startup. Stopping both old processes prevents an older worker writing while a new schema is being installed. Verify health, inspect migration logs, check source status and repeat a known query.

The Notion document-source upgrade specifically requires coordinated app/worker replacement. Do not run an old binary against that upgraded schema.

## Recover or roll back

If a new image fails, inspect the error before repeatedly restarting. Do not delete volumes to repair a configuration issue. Database migrations may not support an older application image: restore a known compatible backup into an isolated recovery stack rather than assuming image rollback reverses migrations.

On Rancher Desktop, an unexpectedly empty or tiny Docker data disk can indicate an unmounted persistent disk. Check the runtime's storage before creating a new installation that appears to have lost its data.

## Stop without deleting data

```bash
docker compose down
```

On Kubernetes, `helm uninstall` keeps the persistent volumes and the generated Secret. Adding `-v` to Compose deletes volumes. Keep it out of routine restart and upgrade procedures.
