Skip to content

Upgrades and rollback

The edge upgrade path is intentionally more cautious than the client path. It can back up the current binary, DB, and env file, install a new daemon, restart, verify health, and roll back on failure.

Upgrade and rollback diagram

Run on the edge:

Terminal window
cd ~/tunneled
sudo ./scripts/upgrade-edge.sh --build

Run on the edge:

Terminal window
cd ~/tunneled
sudo ./scripts/upgrade-edge.sh --docker-build --goos linux --goarch amd64

Useful flags:

FlagMeaning
--binary <path>Install a prebuilt mytunneld binary.
--service <name>systemd service name, default mytunneld.
--buildBuild with local Go before install.
--docker-buildBuild with Docker before install.
--docker-image <image>Docker image for build, default golang:1.25.
--goos <os>Target GOOS, default linux for edge.
--goarch <arch>Target GOARCH, default inferred from host.
--upgrade-backup-dir <dir>Backup root, default /var/backups/mytunneld.
--no-backupSkip backup, advanced only.
--skip-restartInstall binary but skip restart and verification.

After installing the new binary, upgrade-edge.sh verifies:

  • systemctl restart <service> succeeds.
  • The service is active.
  • Caddy Admin API responds at the configured URL.
  • mytunneld ctl health --json returns status: ok.

If verification fails and backup is enabled, the script restores the previous binary and DB snapshot, then restarts the service.

Default backup root:

/var/backups/mytunneld

Each upgrade creates a timestamped directory:

/var/backups/mytunneld/upgrade-YYYYMMDDTHHMMSSZ/

It can contain:

  • mytunneld.prev
  • leases.db.prev
  • mytunneld.env.prev

Local Go:

Terminal window
cd ~/tunneled
./scripts/upgrade-local.sh --build

Docker:

Terminal window
cd ~/tunneled
./scripts/upgrade-local.sh --docker-build --goos darwin --goarch arm64

Prebuilt binary:

Terminal window
./scripts/upgrade-local.sh --binary ./bin/mytunnel

If the automatic rollback could not run, restore from the backup directory.

Terminal window
sudo install -m 0755 /var/backups/mytunneld/upgrade-YYYYMMDDTHHMMSSZ/mytunneld.prev /usr/local/bin/mytunneld
sudo cp -f /var/backups/mytunneld/upgrade-YYYYMMDDTHHMMSSZ/leases.db.prev /var/lib/mytunneld/leases.db
sudo systemctl restart mytunneld
mytunneld ctl health --json

Only restore the DB snapshot if you accept losing lease changes made after that backup.

Dry-run edge uninstall:

Terminal window
sudo ./scripts/uninstall-edge.sh --dry-run

Remove edge service, binary, and config while preserving data:

Terminal window
sudo ./scripts/uninstall-edge.sh

Remove data too:

Terminal window
sudo ./scripts/uninstall-edge.sh --purge-data

Client uninstall dry-run:

Terminal window
./scripts/uninstall-local.sh --dry-run

Client uninstall:

Terminal window
./scripts/uninstall-local.sh

Before cutting a public release:

Terminal window
go test -race ./...
go test ./... -count=1
go run golang.org/x/vuln/cmd/govulncheck@v1.1.4 ./...
make build
make release-client
make checksums

If local Go or shellcheck is unavailable:

Terminal window
make verify-docker