Running the service
The operator tool
contactmesh, on the server: status, checks, backups, restores and updates, without Docker commands.
contactmesh runs on the server ContactMesh is installed on, in the directory that holds
compose.yaml and .env. It looks after the installation: whether it is complete, whether it answers,
its backups, and moving it to a new release. It drives Docker for you and shows every command before it
runs it, so nothing happens that you could not have typed yourself.
./contactmesh # a menu of everything below./contactmesh status # one command, for a scriptThe contactmesh file beside compose.yaml runs the build for the server: contactmesh-linux-x64,
contactmesh-linux-arm64 or contactmesh-osx-arm64 beside it, or, in a checkout with the .NET SDK 10.0.4xx, the
tool’s source. It works on its own directory wherever you start it from; --dir names another.
On Windows, contactmesh.cmd beside it, or .\contactmesh.ps1 in PowerShell, runs
contactmesh-win-x64.exe or contactmesh-win-arm64.exe the same way. On Windows Server the tool runs
where Docker does, in the Linux VM or in WSL: see Running on Windows Server.
What it does
Section titled “What it does”| Command | What it does |
|---|---|
status | The containers, the version and commit running, the newest migration, plan mode, free disk space |
check | Whether the installation is complete and sane: .env and what a release added to it, PUBLIC_ORIGIN, the protection key, the port, Docker |
verify | Whether the running deployment answers: the API’s health, the worker, the migrations, the schedules |
backup | A backup of the database now, into backups/ |
backups | The backups: where they are, their size, date and version |
restore | Puts a backup back; import does the same for a backup from another server |
update | Moves to a newer release |
upgrade | Moves to a release that asks something of you first, such as a new major version |
logs | Follows the logs of the API and the worker |
licence | The licence: its state, modules, limits with what is in use, and dates. licence install <file> installs one |
reset-access | Gives an account nobody can sign in to a temporary password |
status, check, verify and backups change nothing. They read the database in sessions the
database itself keeps read-only, and print no password or key: check describes the protection key by
its length and its characters.
Checking an installation
Section titled “Checking an installation”Run check after editing .env and before starting. It finds what would stop a start before the start
does — a missing database password, a protection key still set to an example value, a PUBLIC_ORIGIN
that is not an https address, a first administrator named admin, a port another program holds, a
Docker too old — and the mistakes that start cleanly and run wrong: a line in .env that sets a value to
its own comment, a variable nothing reads, the API and the worker on two different versions.
After an upgrade, check also names the variables .env.example has and .env does not, which is how
a variable a release added shows up: one to decide is a warning, an optional one with its default a
note. It compares names only, never values.
Run verify once it runs. Each finding is ok, note, warn or FAIL; only a failure ends the
command with an error.
Backups
Section titled “Backups”backup takes a backup of the database with the product’s own backup script, run inside the database’s
container, and puts it in backups/ beside compose.yaml, readable by its owner only. backups lists
them. CONTACTMESH_BACKUP_DIR keeps them elsewhere, on another disk for instance.
restore puts a backup back. It shows what it will do and has you type the backup’s name; then it takes
a fresh backup of what is there now, stops the API and the worker, empties the database, restores the
backup, runs the migrate step, which grants the API’s database role again (a backup carries no grants), and
starts the API and then the worker. Before it starts, it says whether .env holds the
protection key the backup was taken with. The people erased since the backup was taken stay erased: the
erasures the database held are put back into the restored one, and the worker erases them again when it starts
(Erasing a person). Afterwards, read every source list again and reconcile the
recipients it affects.
Updating
Section titled “Updating”update moves both images to a newer release: the newest in the registry, or the one you name with
--version. It shows its plan, asks, and then:
- backs up the database,
- downloads both images, so a release that cannot be downloaded changes nothing,
- checks that the licence’s maintenance covers the release: one built after it ended is refused, since it would stop delivery, and one whose image does not say when it was built is warned about,
- writes the release into
.env, keeping the old file beside it, - stops the worker and the API,
- runs the migrate step, which brings the database up to date and keeps the role the API and the worker log in as,
- starts the API on the new release,
- starts the worker once the API answers, and
- checks the result as
verifydoes.
The worker stops first because a new release can rename what the database keeps for the schedules, which
the old worker could no longer read. With a compose.yaml from before 1.9.0, which has no migrate step,
only the worker stops, and the API brings the database up to date as it starts. Since 1.9.0 update lists
what a release offers as a choice, such as a database role of its own, and goes on. If a step fails, the
tool says exactly how to go back from where it stopped: nothing to do, the old .env put back, or — once the database has been brought up to date,
which the old release refuses to start on — a restore of the backup taken in step 1.
upgrade is the same, for a release that asks something of you first, which is what a new major version
means. It shows the release notes and the steps to take before, checks the ones it can — an optional one reads
optional until it is done — and has you type the version. update refuses such a release and sends you to upgrade.
Upgrading describes the same steps done by hand.
In a script
Section titled “In a script”--yes answers every question with yes; without it, and without a terminal to ask in, the answer is no.
--dry-run shows the plan and every command in it, and runs none. status, check, verify and
backups print JSON with --json. The exit code is 0 when everything worked, 1 when something failed,
and 2 when the tool refused before doing anything: in a directory without compose.yaml, for instance.