TachEmail r90
Docs / Operate / Back up and restore

Back up and restore

Nightly and on-demand backups, copies off the VM, and restoring a backup into a new directory.

Built from commit f569b4a on Nov 14, 2026

This page is generated from the maintained install guide, GUIDE.md, at source commit fa247a8. Keep the signed guide that came with your installed release.

Back up

Tach’s server backs up its own database. Every night at 04:30 UTC it takes an online backup while it keeps serving, then checks the copy: SQLite’s integrity and foreign-key checks, a restore of the copy into scratch space, and matching counts and hashes for usage records, receipts and batch acknowledgements. Only a backup that passes is kept, in the backups directory inside data_dir, and the new snapshot and its receipt are fsynced before any older pair is pruned, keeping retention of them. If the server was not running at 04:30 UTC, it runs the missed cycle when it starts. To run the same cycle now and see its result:

sudo tach backup
sudo tach status

tach backup runs the cycle in the installed server image and prints its receipt: status, attempted_at (Unix time), the backup file name, its sha256, the check results, and off_host (copied when the Azure Blob copy is set up). The backup file is DATA_DIR/backups/ followed by that name, such as /var/lib/tach/data/backups/tach-backup-20261102T043000123456789Z-UUID.sqlite.

tach status shows the same receipt under backup, and Health in the web app shows it under Scheduled backups and restore. tach status exits non-zero when the last cycle failed, a running cycle exceeded its bound, or the first receipt is still missing 26 hours after backup enablement. Restarting does not reset that first-receipt deadline. A missing enablement record is also overdue. Watch that exit code or Health with your existing monitoring; this package sends no alerts.

A cycle fails with a named class. Until a replacement snapshot and its receipt are durably synced, every earlier pair is kept. Only then may retention prune older pairs. A later pruning or status-write error still leaves the new pair restorable. Failure causes:

  • backup_size_limit: the database exceeds max_mib (default 256 MiB). Raise it above the database size (maximum 16384 MiB), then rerun the installed package’s install command with your edited source config. The default is a starting value: tach status warns with backup_near_size_limit from 80% of the cap (see Safety warnings), so raise it then, before a backup fails.
  • backup_disk_space: free space is below 3 × max_mib + 64 MiB. Extend the disk or free unrelated files, not retained backup evidence.
  • backup_integrity_failed, backup_snapshot_failed or backup_restore_drill_failed: preserve the current disk; follow Backup-blocked recovery.
  • backup_copy_failed: check the copy service journal, managed identity, container RBAC and network; retry after correcting them. This is the only failure whose hint points at the Blob journal.
  • backup_cycle_timeout: the whole cycle exceeded max(300, ceil(max_mib × 600 / 1024)) seconds. Check disk throughput and copy connectivity.
  • backup_storage_failed, backup_publish_failed, backup_status_failed or backup_cycle_failed: check disk permissions, I/O errors and the server journal. The last is a worker crash/resource-limit fallback, not an integrity verdict. Preserve the disk if the cause is unclear.

The copy shares the cycle’s bound; it does not get an additional three hours. A busy nightly cycle returns backup_already_running. A busy host operation also names contention rather than an opaque lock error; tach status remains available and shows the last receipt and Health. Retry when the operation ends.

A backup on the VM’s own disk does not survive the loss of that disk. Until an off-host copy is configured, install and tach status warn with backup_off_host_unset, and with alerts_unset while no alert address is set (see Safety warnings). Copy backups off the VM: set up the Azure Blob copy, or copy the files with your existing custody process and compare the SHA-256 at the destination with the receipt’s sha256. Test recovery from the off-VM copy separately. Local backups now live in the server-writable data mount: a compromised serving container can delete them and their receipts. Only separately controlled off-VM custody isolates them from that container.

Packages such as 0.3.0 used backup.directory, tach-backup.timer, tach-backup.service and /etc/tach/last-backup.json. The first image upgrade from 0.3.0 is still performed by the 0.3.0 host tool. Then edit your source config: remove backup.directory, choose max_mib above your current database size, and keep retention between 1 and 90. Rerun install from the new package directory. Only after the new service restarts successfully does the installer disable the old timer, clear its failed service state and remove the old units/receipt. A failed rerun before that point leaves the timer enabled; correct the reported cause and rerun. Do not leave both schedulers indefinitely.

Old backup files stay where they are. Allow space for those files and retention × database size, the live database/WAL, and 3 × max_mib + 64 MiB free for the new cycle. The default 256 MiB cap refuses larger databases and blocks later image switches. Monitoring the retired unit or old receipt no longer tracks backups: monitor sudo tach status’s exit and receipt or the administrator Health backup status instead. Optional operator notices are described under Operational notices; without a configured route the package sends none.

Backup-blocked recovery

An upgrade or rollback whose pre-switch backup fails leaves the current image and ledger in place. There is no bypass and no automatic older-snapshot restore. Correct size, disk, permissions or copy failures as above, run sudo tach backup until it passes, then retry the switch. When the off-host copy itself is broken, including a copy fault that the newer package fixes, IT may first preserve all existing backups off-VM. Then remove the copy settings from the source config: both azure_account and azure_container, or both copy_target and copy_config_file. Rerun the installed package’s installer. This deliberately disables off-host copying (the next receipt says unconfigured), not local verification. Take and independently copy a successful local backup, then upgrade. Restore the copy settings and rerun the new package’s installer, then sudo tach backup must report off_host as copied.

If integrity/drill fails, or the current image’s backup implementation itself is broken, stop tach-selfhost and preserve a cold copy of the entire current data directory, including WAL, sidecars and every earlier backup, on separately controlled storage. Keep the original disk untouched. Work only on an isolated clone using a verified fixed package or IT’s database-recovery tools; validate full integrity, receipts, exact ACKs and Answers and take a successful verified backup there before returning it to service. If only the old backup implementation is broken and the ledger is healthy, install the fixed signed package fresh on a separately addressed recovery VM. Checkpoint the isolated cold clone, not the original, with Python’s SQLite connection (PRAGMA wal_checkpoint(TRUNCATE)), require a non-busy result, then set PRAGMA journal_mode=DELETE on that clone and require delete before closing it. Keep its WAL/sidecars until checkpoint success is confirmed; the standalone copy must no longer use WAL journal mode. Use that clone’s standalone tach.sqlite as the Restore input on the recovery VM; then follow Restore’s service/config switch and comparison steps. Host restore refuses WAL/journal sidecars, since copying a main file alone can omit accepted WAL commits. Keep all originals until IT approves the recovered state. Never open the same volume with two servers, drop immutable records to make a check pass, or replace current data with an earlier backup. If those comparisons cannot pass, keep serving stopped: this is a data-recovery incident, not permission to lose accepted usage. Record the cause, original/fixed package revisions and comparison results for IT’s change approval. A passing backup is required before any normal image switch.

Restore

Restore never overwrites an existing directory or the live database. It refuses destinations below server-owned or other lower-trust-writable parents (choose a root-owned recovery location outside the data mount), symlinks in the source path and any WAL/journal sidecars (use a standalone backup, never a copied live main file), verifies a retained backup against its adjacent .sqlite.json receipt (keep the two together), and runs full SQLite integrity and foreign-key checks before restoring. A refusal leaves no new destination; a failed image restore removes only the directory this invocation created, so you can retry the same command. A receipt is a corruption check, not a signature: the serving container can change local backups and receipts. Trust a separately kept off-VM digest if the host may have been compromised. The backups the cycle kept on this VM are in DATA_DIR/backups (list them with sudo ls /var/lib/tach/data/backups) and already have UID/GID 65532 and mode 0600. For a copy brought back from off-VM custody, compare its SHA-256 with the receipt’s sha256 (an Azure Blob copy is named tach-backup-SHA256.sqlite), then set its owner and mode:

sudo sha256sum /ABSOLUTE/PATH/TO/BACKUP.sqlite
sudo chown 65532:65532 /ABSOLUTE/PATH/TO/BACKUP.sqlite
sudo chmod 600 /ABSOLUTE/PATH/TO/BACKUP.sqlite

Then restore into a new directory:

sudo tach restore /ABSOLUTE/PATH/TO/BACKUP.sqlite /var/lib/tach/recovered

The restored file is /var/lib/tach/recovered/tach.sqlite. Usage records, receipts and batch acknowledgements survive; sessions and pending sign-in codes do not.

To recover on a separate VM with its own address, keep collectors disconnected, install the same verified package, and restore as above. Then stop Tach, set data_dir to the recovered directory in both the installed config and your source config, and rerun the install command from the package directory. The rerun points the service and its backup cycle at the recovered directory:

sudo systemctl stop tach-selfhost
sudoedit /etc/tach/config.toml
sudoedit /root/tach-config.toml
sudo ./install.sh --config /root/tach-config.toml --public-key ../trusted-release.pub
sudo tach status

The restored people and keys replace the recovery VM’s own: sign in as the original administrator and keep using the original collector keys, not the recovery VM’s new first-admin keys file. Compare receipts and answers before you switch users to it. Keep the original disk intact. Never replace newer accepted usage with an older backup.

Other off-host targets

The same verified backup cycle and host copy service can use S3-compatible storage, Azure Blob, Google Cloud Storage, or an IT-mounted directory through one pinned rclone runner. Do not enable a second backup scheduler. Leave azure_account and azure_container empty when using copy_target. Existing Azure CLI managed-identity installations may retain their existing configuration; this option does not silently migrate their credentials.

Install the host copy runner

On a connected staging host, download https://downloads.rclone.org/v1.71.2/rclone-v1.71.2-linux-amd64.zip. The archive SHA-256 is sha256:ab9fa5877cee91c64fdfd61a27028a458cf618b39259e5c371dc2ec34a12e415. Compare it before extracting. Transfer the verified archive for disconnected hosts. Install its rclone binary as /var/lib/tach-copy/rclone, root-owned, mode 0755, with root-owned ancestors not writable by other users. Every copy checks binary SHA-256 sha256:0e8ba506e078ab702c54abaa94b4bd3d172640a4c260acb76100cdcbda0aadf7. A different version refuses; do not use rclone selfupdate. The upstream archive also includes rclone’s license; retain it with the tool. No download occurs in the serving container or during a backup.

Configure one destination

Create /root/tach-rclone.conf, root-owned mode 0600, with exactly one [custody] section. Credential-file ancestors must also be root-owned and not writable by other users; prefer /root or /etc/tach. Configure it privately, never in a shell argument or log. Tach accepts only these backend options:

  • S3: type = s3, provider, access_key_id, secret_access_key, region, endpoint, force_path_style, env_auth = false. For a compatible endpoint, use provider = Other, its HTTPS endpoint and force_path_style = true when required. Create the bucket first: Tach never creates or checks buckets, so a key limited to objects in that one bucket works. Grant read/write of the selected prefix and bucket listing as needed; allow deletion only of temporary objects, not published backup names. IT owns IAM and provider qualification.
  • Azure: type = azureblob, account, key, sas_url, use_msi. Use a private scoped credential or the VM managed identity with the required read/write Blob role. Keep SAS URLs exclusively in this private file.
  • GCS (recipe only, not certified): type = google cloud storage, service_account_file, project_number, env_auth = false. The referenced JSON credential must also be root-owned mode 0600. Grant object read/write and required listing. Real GCS copy/readback/restore qualification is required before treating this recipe as supported.
  • Mounted directory: type = local, with no other options. IT must mount storage from an independent machine before backup. In the TOML set copy_mount to the absolute mountpoint and copy_target to custody:/mnt/tach-custody/backups (adjust the mountpoint). Pre-create the destination writable by numeric UID/GID 65534, the unprivileged local runner. Do not make the share world writable. Symlink destinations are refused. A missing mount fails rather than filling the original disk. Configure systemd mount dependencies in IT’s mount units; never put the live ledger or data_dir on this share. IT is responsible for ensuring the mount really is independent storage, not a bind mount of the source disk.

In the existing TOML [backup] table set copy_config_file to the private configuration path and copy_target to custody:BUCKET/PREFIX for object storage (only letters, digits, underscore, dash, dots and slashes; no traversal). Run the guide’s existing validate and install commands to activate settings, then sudo tach backup and sudo tach status. The existing Health backup receipt must show off_host copied. A destination/credential/readback failure fails the cycle, appears in status and Health, and preserves older local pairs. Fix the destination then retry sudo tach backup; no service repair is needed. Provider error output is deliberately suppressed to avoid logging signed URLs.

Objects are named tach-backup-SHA256.sqlite, with a .sqlite.json companion containing size and SHA-256. Tach reads the entire uploaded SQLite object back and hashes its bytes; it never trusts an ETag. It copies only the completed, validated and restore-drilled staged inode, not the live database. A retry first reads and reuses a matching verified pair without rewriting it. New or repaired files use unique temporary names, full readback and publication (local storage uses an atomic same-directory rename); it never mirrors or deletes older remote backups. Interrupted copies can leave .tmp- objects; they are not restore candidates and may be removed by IT after confirming no cycle is active. Object backends need read/write, server-side copy and deletion of temporary objects only; do not grant deletion of published backup names. Missing copy credentials fail backup, not serving, status or restore. Configure retention/immutability policies separately in IT’s storage. Do not enable a lifecycle policy shorter than your recovery needs.

Recover after losing the source disk

On an independent supported recovery VM, obtain the signed package and private custody credentials from IT’s separate recovery custody. Download one complete .sqlite and its companion .json from the chosen prefix with the pinned tool. Check the downloaded length and SHA-256 against that metadata (and retain the original cycle receipt separately when possible). Never select by ETag or filename alone. Use the existing documented sudo tach restore BACKUP_FILE NEW_EMPTY_DIRECTORY procedure; it validates the ledger and invalidates old sessions/codes without changing Facts, receipts or batch ACKs. A copy is not a recovery qualification: rehearse this on a separate target before production. S3 protocol compatibility does not certify every provider’s IAM. Azure and GCS real-provider certification require disposable-account copy/readback/restore receipts; these recipes alone do not earn those claims.

Enter to openEsc to close