# Upgrades and backups

## Backups

State is the data directory (`FUZZY_DIR`). Copy it to back up. Files are short-lived, so many operators skip backups; accounts and keys are the part worth keeping. Stop writes or copy while idle for a consistent snapshot.

Keys are stored as hashes, so a backup does not reveal anyone's access key. It does contain emails, names and the link activity logs: protect it like personal data.

## Servers set up before the rename

A server installed when this program was called Siso keeps working as it is: the `siso` service, `/opt/siso`, `/etc/siso/env` and `/var/lib/siso` are only locations, and nothing has to be moved. `fuzzyshare-deploy` detects the layout and restarts whichever service you have. The old `SISO_*` settings in the environment file still apply.

## Upgrades

Replace the binary and restart the service:

```sh
sudo install -m 755 fuzzy /opt/fuzzyshare/fuzzy
sudo systemctl restart fuzzyshare
curl -fsS http://127.0.0.1:8080/health
```

The on-disk layout is described in [Architecture](contributing-architecture.md#storage). Accounts made before named keys get one key called `default` the first time the new server starts, and the old key keeps working.

## Rollback

Keep the previous binary (for example as `fuzzy.prev`) and copy it back if a release misbehaves.

## Automatic deploys from GitHub

`.github/workflows/deploy.yml` deploys after CI passes on `development`. It does nothing until you opt in.

1. On the server, install `deploy/fuzzyshare-deploy` as `/usr/local/bin/fuzzyshare-deploy`. It receives the new binary on standard input, installs it, restarts the service and rolls back if `/health` does not answer.
2. Create a key just for CI and authorize it so it can run only that script:
   ```sh
   ssh-keygen -t ed25519 -N "" -C fuzzy-ci -f fuzzy_ci
   # in ~/.ssh/authorized_keys on the server:
   command="/usr/local/bin/fuzzyshare-deploy",restrict ssh-ed25519 AAAA... fuzzy-ci
   ```
3. Add repository secrets `DEPLOY_SSH_KEY`, `DEPLOY_HOST` and `DEPLOY_KNOWN_HOSTS` (the output of `ssh-keyscan -t ed25519 HOST`, checked against a fingerprint you trust).
4. Set the repository variable `DEPLOY_ENABLED` to `true`.

## CLI downloads

The same pipeline builds the CLI for five platforms plus `checksums.txt` and `VERSION`, and ships them to the server, which serves them from `FUZZY_DL_DIR` at `/dl/`. This keeps the install one-liner and `fuzzy update` working for a private repository. The deploy script accepts them through the same restricted SSH command, validating every name and size.

## Logs

FuzzyShare logs one line per request to standard output, using the route pattern rather than the path, so share tokens never reach the log.
