---
title: "Operate a self-hosted install"
description: "Run a self-hosted Anlyon install day to day with the anlyon-selfhost command: status, logs, upgrades that back up first and roll back on their own, backups, restores, and getting back in when you are locked out."
sidebar:
  label: Operate
---

The one-line installer adds the `anlyon-selfhost` command to the server. It runs the install from then on. Every command needs root, so run it with `sudo`.

## Use anlyon-selfhost

| Command | What it does |
| --- | --- |
| `sudo anlyon-selfhost status` | The address, the edition, the running images, whether the server is ready, the latest backup and the backup schedule, then the containers |
| `sudo anlyon-selfhost logs server -f` | Recent logs of one container, `server`, `dashboard`, `caddy`, `postgres` or `redis`, or of all of them without a name. `-f` keeps following; `--tail 500` shows more lines (200 by default) |
| `sudo anlyon-selfhost upgrade --version <x.y.z>` | Back up, then move to that release. See [Upgrade](#upgrade) |
| `sudo anlyon-selfhost backup` | Back up the database, the server's files and the settings. See [Back up and restore](#back-up-and-restore) |
| `sudo anlyon-selfhost restore <archive>` | Restore a backup into this install |
| `sudo anlyon-selfhost preflight` | Check the server again, changing nothing |
| `sudo anlyon-selfhost uninstall` | Stop and remove the containers, keeping everything else |
| `sudo anlyon-selfhost help` | Every command and flag |

An install from a clone has no `anlyon-selfhost`. Run `docker compose` in `deploy/self-host` instead: `docker compose ps` for status and `docker compose logs server` for logs.

## Upgrade

Read the [release notes](https://github.com/AnlyonHQ/anlyon/releases) first, above all before a major version. Then name the release to move to:

```bash
VERSION=1.0.0   # the release you are moving to
sudo anlyon-selfhost upgrade --version "$VERSION"
```

1. **It backs up first**

    The same backup as `anlyon-selfhost backup`, before anything changes.

2. **It fetches the new version**

    It builds or pulls the new images. If that fails, nothing that is running changes.

3. **It starts the new version and checks it**

    Database migrations run as the server starts. The upgrade waits for the server to report ready.

4. **It goes back on its own if the new version is not ready**

    It puts the previous images back and starts them. If the new version had already changed the database before it failed, the upgrade prints the `anlyon-selfhost restore` command for the backup it took first.

### Upgrade an install from a clone

Back up first (see [Back up an install from a clone](#back-up-an-install-from-a-clone)), then:

```bash
git pull
cd deploy/self-host
docker compose up -d --build
```

Migrations run as the server starts.

## Back up and restore

```bash
sudo anlyon-selfhost backup
```

A backup is two files, kept apart:

| File | What it holds |
| --- | --- |
| `/opt/anlyon/backups/anlyon-<time>.tar.gz` | The database, the server's files (the `anlyon_data` volume) and the `.env` file without its keys. Never the root key |
| `/opt/anlyon/backup-keys/anlyon-<time>.keys` | Only the root key |

Both are readable by root only. Copy them off the server, **to different places**: the archive to your backup storage, and the keys file to a password manager or a vault. Whoever has both can read the stored secrets and connected accounts.

The newest 7 backups are kept. `--keep 14` keeps more.

### Back up on a schedule

```bash
sudo anlyon-selfhost backup --schedule daily
```

That backs up every day at 03:17 server time, with a systemd timer, or with cron where systemd does not run. `--schedule weekly` backs up once a week, `--at 02:00` picks another time, `--keep` sets how many to keep, and `--schedule off` stops it. `anlyon-selfhost status` shows the latest backup, its keys file and the schedule.

### Restore a backup

List the backups, then restore one by its file name:

```bash
sudo ls /opt/anlyon/backups
sudo anlyon-selfhost restore /opt/anlyon/backups/anlyon-<time>.tar.gz
```

It replaces the install's database and the server's files with the backup's. Accounts, actions, approvals and receipts made since the backup are lost, so it asks you to type `restore`, and it backs up the current state before it starts.

The archive records a fingerprint of the root key it was made under, never the key. If that is not the root key in `.env`, the restore stops: restored, the stored secrets and connected accounts could not be read. To restore on a new server, put the `ANLYON_ROOT_KEY` from the backup's keys file into `/opt/anlyon/.env` first. `--force` restores anyway, without the secrets.

### Back up an install from a clone

Back up these, in `deploy/self-host`:

```bash
# The database
docker compose exec -T postgres sh -c 'pg_dump -U "$POSTGRES_USER" -d "$POSTGRES_DB" -Fc' > anlyon.dump

# The server's files: the anlyon_data volume
docker compose run --rm --no-deps -T server tar -C /app/data -cf - . > anlyon-data.tar
```

Keep a copy of the `.env` file too and, above all, of `ANLYON_ROOT_KEY`, stored apart from the rest.

Redis holds short-lived state, such as limit reservations in flight and queues, and is rebuilt when it starts. Back it up too only if you cannot accept losing work that was in flight.

## Uninstall

```bash
sudo anlyon-selfhost uninstall
```

It stops and removes the containers and the scheduled backups. The database, `.env`, the backups and their keys stay. Start it again with `cd /opt/anlyon && sudo docker compose up -d`.

```bash
sudo anlyon-selfhost uninstall --purge
```

`--purge` deletes everything for good: the containers, the database and its volumes, the images, and `/opt/anlyon` with its `.env`, root key, backups and backup keys. It asks you to type `purge` first. Copy anything you want to keep off the server before you run it. Docker, swap and firewall rules are left as they were.

## Locked out

If nobody can sign in as an instance admin, create a new instance admin from the server. In the install directory, `/opt/anlyon` with the one-line installer or `deploy/self-host` from a clone:

```bash
cd /opt/anlyon
sudo docker compose exec -e ANLYON_ADMIN_PASSWORD='<a long password>' server \
  node dist/scripts/create-admin.js --email you@example.com --name "Your Name"
```

The password comes from `ANLYON_ADMIN_PASSWORD` rather than the command line, and must be at least 12 characters. The command creates an account that can sign in at once, with a workspace it owns, and makes it an instance admin. It refuses an email address that already has an account, and then changes nothing. With `SIGNUP_MODE=closed`, this is also how accounts are created.

## Related

**[Configure](/self-hosting/configure)**

Email, file storage, sign-up, OAuth apps and telemetry.

**[Security](/self-hosting/security)**

Where credentials live, and the root key.
