> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tablepro.app/llms.txt
> Use this file to discover all available pages before exploring further.

# License and upkeep

> Install, check and renew the self-hosted server's license, upgrade it one release at a time, back it up and restore it, and the log events to alert on

Server commands on this page, such as `license install`, run in a one-off container. [Docker Compose](https://docs.tablepro.app/self-hosted/docker-compose.md#run-a-command) and [AWS Fargate](https://docs.tablepro.app/self-hosted/aws.md#run-a-command) show how on each platform.

## License

The license file is one signed line of text that TablePro issues for your API address. It sets the seats, the features and the end of the license, and every seat includes Pro on the Mac. A staging server needs a file of its own for its own address.

`license install <file>`, or `license install -` to read the file from standard input, checks the file and installs it in place of the one installed. It refuses a file that:

* was not signed by TablePro, or names another address than `https://` plus `API_HOST`;
* is past its grace;
* is older than the installed file of the same license;
* is perpetual, and its maintenance ended before this release.

`license status` prints the license and file IDs, the type, the seats, the end and the grace, or a perpetual file's end of maintenance, the address, the features and the state, then `seats taken: <taken> of <seats>`. With no file installed, it prints `no license: no license is installed`.

### Renew

A renewal, or a change of seats, is a new file: install it the same way. A file with fewer seats than are taken keeps everyone who has one, and no one new signs in until enough seats are freed under [Remove someone](https://docs.tablepro.app/self-hosted/roles.md#remove-someone).

### When a license ends

A file with an end date has a grace after it, written into the file: 7 days for a monthly license, 30 days for every other.

| State | From | What works |
| - | - | - |
| `active` | Until the end date | Everything |
| `grace` | The end date, until the grace ends | Everything. The Mac shows the grace under **License** in **Settings > Account** |
| `lapsed` | The end of the grace | Pulls and administration. The server refuses Team Library publishes with `license_expired`, and Macs keep only Team Library; see [Company server](https://docs.tablepro.app/features/company-server.md#what-is-different-on-a-company-server) |

A perpetual file has no end date. It covers every release dated up to its end of maintenance, and keeps them running for good. `migrate up`, `serve` and `license install` refuse a later release and name the last date the file covers; `migrate up` refuses before it changes the schema. Extending maintenance is a new file with a later date.

## Upgrades

* **One minor version at a time**, such as 0.1 to 0.2, then 0.2 to 0.3. Each release's migrations only promise that the release before it runs on the new schema. To skip a minor version, stop the old server first.
* **Back up first.** Migrations only go forward, so going back to the earlier release means restoring the backup taken before the upgrade.
* **A perpetual license** must cover the new release; `migrate up` refuses it otherwise, before it changes anything.

With Docker Compose, set `TABLEPRO_IMAGE` in `.env` to the new digest, then run the migrations while the old server still serves, and start the new one only once they exit 0:

```bash theme={null}
docker compose run --rm migrate
docker compose up -d --no-deps app
```

> [!WARNING]
>
> A plain `docker compose up -d` removes the old `app` before `migrate` runs, so a migration that fails leaves nothing serving.

On AWS, register a new revision of the task definition with the new digest, then deploy it:

```bash theme={null}
aws ecs update-service --cluster tablepro --service tablepro-cloud --task-definition tablepro-cloud:<revision>
```

A new task whose `migrate` fails never starts `app`. The old task keeps serving and the circuit breaker rolls the deployment back, but it cannot undo a migration that ran.

## Back up

Back up the database, and keep the `TABLEPRO_CREDENTIALS` value next to the backups: a database restored without its `identity-tokens` key cannot read the IdP refresh tokens it holds.

* **Docker Compose:** `docker compose exec -T postgres pg_dump -U tablepro -Fc tablepro > tablepro.dump`
* **AWS:** RDS automated backups, and `aws rds create-db-snapshot` before each upgrade.

## Restore a backup

A restore rolls the Team Library back, while the Macs hold positions past it. `sync new-epoch` makes every Mac take a fresh copy of the library from the restored server.

**1. Stop the server**

`docker compose stop app`, or set the service's desired count to 0.

**2. Restore the database**

With Compose, into an empty database:

```bash theme={null}
docker compose exec -T postgres dropdb -U tablepro tablepro
docker compose exec -T postgres createdb -U tablepro tablepro
docker compose exec -T postgres pg_restore -U tablepro -d tablepro < tablepro.dump
```

On AWS, restore the RDS instance to a point in time as a new instance, and point `DATABASE_URL` in a new task definition revision at it.

**3. Start a new library epoch**

Once, before the server starts: `docker compose run --rm --no-deps app sync new-epoch`, or the same command as a one-off task on AWS.

**4. Start the server**

`docker compose up -d`, or the desired count back to 1.

> [!CAUTION]
>
> Everything written after the restore point is lost, including what Macs published after it. The Macs take the restored library and drop their newer copy.

## Alerts

The server writes one JSON object per line to standard output, with `level` and `msg`. Alert on:

| Signal | Means |
| - | - |
| `"level":"ERROR"` from any container. In CloudWatch, the metric filter `{ $.level = "ERROR" }` | Something failed |
| `migrate` exiting non-zero, or `app` restarting | A start or a deploy failed |
| The ALB's `UnHealthyHostCount` at 1 or more for 5 minutes, and `HTTPCode_Target_5XX_Count` | The server is down or failing requests |
| RDS `FreeStorageSpace` under 2 GB, `CPUCreditBalance` running low, `FreeableMemory` | The database is running out of room |

The server also logs these events once a day and at each start. A metric filter `{ $.msg = "license*" }` catches the license ones, along with `license active` at INFO.

| `msg` | Level | When |
| - | - | - |
| `license not installed` | WARN | No license file verifies |
| `license expires soon` | WARN | From 30 days before the end date |
| `license expired, in grace` | WARN | Past the end date, within the grace |
| `license lapsed, library pushes refused` | ERROR | Past the grace |
| `license maintenance ends soon` | WARN | A perpetual file, in the 30 days before its maintenance ends |
| `idp certificate expiring` | WARN | A trusted SAML signing certificate ends within 30 days |
| `idp certificate expired` | ERROR | A trusted SAML signing certificate has ended, and sign-ins it signs fail |

`email not sent` at INFO is expected: a self-hosted server sends no email.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.