TachEmail r90
Docs / Reference / Host commands

Host commands

Every tach host command and flag on a self-hosted VM, and the tach-server people and keys commands you run inside the container.

Built from commit f569b4a on Nov 14, 2026

The self-hosted VM has a host maintenance command and a server command inside its container.

  • tach runs the installation: status, backups, restore, upgrade and rollback. The installer puts it at /usr/local/bin/tach.
  • tach-server is the server program inside the container. You use it to manage people and keys from a script.

Neither is the tach query command people use to read usage from their own computer. That one is described in Query from the terminal.

tach

sudo tach COMMAND [TARGET] [DESTINATION] [--config FILE] [--public-key FILE]

Every command must run as root. Without root it stops with run with sudo/root; config and keys belong to the host administrator. Commands other than validate, serve and copy-backup take an exclusive lock, so two maintenance commands cannot run at once.

Flag Default Used by
--config FILE /etc/tach/config.toml install, validate
--public-key FILE none install, where it is required
-h, --help none Show argparse help and exit without running a command.

An operation failure prints a message starting tach: to standard error and exits 1. Argparse reports invalid command syntax with exit 2. Successful commands exit 0. --config selects the source for install and validate; the other commands use the installed configuration even if that flag is supplied.

install

sudo ./install.sh --config /root/tach-config.toml --public-key ../trusted-release.pub

You run it from the extracted package. install.sh runs tach.py install with the same arguments. It checks the configuration, the VM (Ubuntu Server 24.04, amd64) and the package signature, installs host packages, loads the image, creates the first administrator and their keys, writes the services and Caddy’s configuration, and waits until Tach and HTTPS both report the package’s revision.

When it finishes it prints where the first keys are, /etc/tach/first-admin-keys.json, and the sign-in address.

Rerunning the same package with the same configuration keeps data and keys and ends everyone’s sign-in sessions. Rerunning with a different image stops with existing install: use tach upgrade for an image change.

validate

sudo tach validate [--config FILE]

Checks a configuration file and prints Configuration valid. It changes nothing. See Configuration file for every rule it applies.

status

sudo tach status

Prints one JSON document:

Field Meaning
health The server’s own health answer on the VM, which must report the installed revision.
https The same answer read through Caddy over HTTPS, with your domain as the certificate name.
release The installed image and, after an upgrade, the previous one.
backup The last backup cycle’s receipt: status, attempted_at (Unix time), the backup file name in data_dir/backups, its sha256, the check results and off_host. pending before the first cycle. stale when the last cycle is more than 26 hours old, or a running cycle stopped.

It exits non-zero unless both health checks report the installed revision, and when the last backup cycle is failed or stale. It prints the JSON document first in the backup case. The error says which check failed. See Troubleshooting.

backup

sudo tach backup

Runs the server’s backup cycle now, in the installed server image, with the settings its nightly scheduler uses. The cycle takes an online backup while Tach keeps serving, checks it (schema, SQLite integrity and foreign keys, a restore drill and matching row hashes), copies it to Azure Blob if configured, keeps it in data_dir/backups and removes the oldest backups beyond backup.retention. It prints the cycle’s receipt. A failure keeps every earlier backup and exits 1; backup_already_running means another cycle is running.

Size, free-space, integrity, restore-drill, copy and timeout failures have distinct classes. A busy host operation names contention; status remains available. A hung copy loses its cycle lease and is killed, leaving the next cycle usable without manual service repair.

The server itself runs the same cycle every night at 04:30 UTC, and when it starts if that night’s cycle was missed. No host timer is involved.

restore

sudo tach restore BACKUP_FILE NEW_EMPTY_DIRECTORY

Restores a backup into a new directory as tach.sqlite. It never touches the running database. The destination must not exist yet, have no symlinks in its path, and have root-owned ancestors that are not writable by other users. Choose a recovery location outside the server-owned data mount. Symlinked sources are refused. Retained backups must match their adjacent .sqlite.json receipt; full integrity and foreign-key checks run on a private copy before restore. A failure removes only its own new destination so the command can be retried. Sign-in sessions and pending sign-in codes in the copy are invalidated. Serving the copy requires a separate recovery procedure. See the package guide supplied with your verified release.

upgrade

sudo tach upgrade /ABSOLUTE/PATH/TO/NEW/tach-package-VERSION

Verifies the new package with the signing key saved at install, loads its image, checks that the new image runs the backup cycle on a throwaway database in memory, runs the backup cycle in the current image, then switches to the new image and checks its health. If either check fails, it stops before switching and the current image keeps running. If the new image fails, Tach attempts to return to the previous image on the current database. If that image cannot read the current schema, data is preserved and the service stays stopped. If the package’s image is already running it prints Already running this image.

upgrade changes only the server image. It does not update tach itself, the services, the server settings in /etc/tach/runtime.env or Caddy’s configuration. Rerun install from the new package with the same configuration to update those.

rollback

sudo tach rollback

Probes the previous image on a throwaway ledger and backs up in the current image, then switches back to the image that ran before the last upgrade. If either check fails it stops before switching; an image whose backup cycle does not run is refused. With no previous image it stops with no previous image recorded. Rollback never restores an old backup and never reverses database changes.

serve and copy-backup

The tach-selfhost service runs tach serve to start the container. The tach-backup-copy service runs tach copy-backup when a backup cycle asks it to copy a checked backup to Azure Blob. You do not run either yourself.

tach-server people and keys

Run these on the VM against the running container. Each successful people or keys command prints one JSON document.

sudo docker exec tach-selfhost /usr/local/bin/tach-server SUBCOMMAND
Subcommand What it does
people add --email E [--name N] [--admin] Adds a person as a member, or as an administrator with --admin. Uses billing plan max. Sends no email and creates no key. An existing address is refused and left unchanged.
people import --as ADMIN --file FILE [--apply PREVIEW] Previews a CSV roster whose header row is email,name,role,department, and changes nothing. Each row is listed by its line number as create, update, unchanged or refused, with a preview digest for the whole file. With --apply and that digest, it applies exactly those rows, or stops with preview_changed if anything changed since. ADMIN is your own email as an active administrator, and the file cannot change your own role. --file - reads standard input, which needs docker exec -i. Sends no email and creates no key. Department is the person tag category that Report’s tag:Department grouping reads.
people list Lists everyone with role, status and key counts.
people show E Shows one person.
people set-role E admin or member Changes a role. The change applies from the person’s next request.
people deactivate E Ends the person’s sessions and stops their keys at once. History is kept.
people reactivate E Allows sign-in and unrevoked keys again. Ended sessions stay ended.
keys create --email E --scope ingest or query [--label L] Creates a personal key for E. The result’s key field is the key, shown only here.
keys create --organization --email ADMIN [--label L] Creates an organization key owned by an active administrator. The result has Cowork-only managed_artifacts (export/privacy), never Claude Code or Codex exporter settings.
keys list [--email E] Lists key IDs, owners, scopes and status. Never the keys themselves.
keys revoke KEY_ID Revokes any key. Its next request is refused.

A new key appears only in that command’s output. Send the output straight to a file only root can read, never to the terminal:

sudo sh -c "umask 077; set -C; docker exec tach-selfhost /usr/local/bin/tach-server keys create --email person@example.com --scope ingest --label 'Laptop' > /root/tach-ingest-key.json"

The last active administrator cannot be demoted or deactivated.

Errors and exit codes

A failure writes nothing to standard output and one document to standard error:

{"error":{"code":"unknown_person","message":"..."}}
Exit Meaning
0 Done.
1 Output was not fully delivered. A mutation may already have committed. Inspect the person or key list before retrying.
2 The command or a field is invalid (usage).
3 Refused, or the person or key is unknown.
4 The database is unavailable or busy. Retry.

Codes include usage, person_exists, unknown_person, last_administrator, person_deactivated, invalid_scope, origin_required, unknown_key, key_already_revoked and ledger_unavailable. people import adds not_administrator, preview_changed, too_many_categories, and codes starting roster_ for a file that is not a roster. The message says what to do next and never repeats your input.

If a key’s output was lost, it cannot be shown again. Find it in keys list, revoke it, and create another.

Version

sudo docker exec tach-selfhost /usr/local/bin/tach-server version

Prints tach-server VERSION revision=REVISION. Quote the revision when you ask for help.

Initialization

The installer runs tach-server init --admin EMAIL once against an empty database. It writes one JSON document containing the initial ingest_key and query_key into the root-private first-admin file. Existing people or usage make initialization refuse. Do not rerun it to recover a lost key.

Computer update policy

Inside the running container, tach-server agent-policy [auto|pinned|off] reads or sets the per-instance computer agent policy. Auto is default. Pinned holds only the currently packaged cohort; unavailable pins fail closed, never relabel newer bytes. A rollback to a server without this setting refuses a pin/off policy; deliberately choose auto first if that rollback is intended. Historical version selection is not supported. The endpoint private tach is a separate program from the VM host command and query CLI, and never replaces them on PATH.

Enter to openEsc to close