> Move a whole Homerun instance, say from a box at home to a VPS, with one command run on the server you're leaving. It carries the database, settings, secrets, certificates and…
> Source: https://zedensix.com/homerun/docs/moving-to-another-server · Site index: https://zedensix.com/llms.txt

# Moving to another server

Move a whole Homerun instance, say from a box at home to a VPS, with one command
run on the server you're leaving. It carries the database, settings, secrets,
certificates and every volume across, installs the same Homerun version on the
new server and redeploys every service there. Nothing is deleted on the old
server, so going back is one command.

## Before you start

- **The old server must be a rootful `--mode=full` install**, the installer's
  default. A rootless one moves onto the system daemon first with
  [`--migrate-to-rootful`](https://zedensix.com/homerun/docs/getting-started).
- **The new server** runs Linux on amd64 or arm64 (the architectures can
  differ), with nothing else on ports 80 and 443. Docker is installed there if
  it's missing.
- **Root on the old server logs in to the new one as root over SSH, with a
  key.** The move runs without a prompt, so a password won't do. On the old
  server:

  ```bash
  sudo ssh-keygen -t ed25519
  sudo cat /root/.ssh/id_ed25519.pub
  ```

  and append that line to `/root/.ssh/authorized_keys` on the new server (or run
  `sudo ssh-copy-id root@<new server>` when it still accepts a password). Check
  with `sudo ssh root@<new server> true`. The new server's host key is trusted
  the first time it's seen. A `Host` alias in `/root/.ssh/config` works too, for
  a non-standard port.

- **The old server reaches the new one**, not the other way round: a box behind
  a home router with no open ports can move to a VPS.

## Moving

On the old server:

```bash
curl -fsSL https://raw.githubusercontent.com/zedensix/homerun/main/cmd/installer/bootstrap.sh \
  | sudo bash -s -- --move-to=root@203.0.113.7 --yes
```

The instance keeps the address in `.env`'s `HOMERUN_HOST`. Pass
`--domain=<domain or IP>` when it changes, which is required when the old server
was reached by its own IP address: that address stays behind.

The move goes in six steps, printed as it runs:

1. **Check the new server**: it answers over SSH as root, on a supported
   architecture. Nothing has changed anywhere yet if this fails.
2. **Docker on the new server**, installed with Docker's own script when it's
   missing.
3. **Stop Homerun here.** The database is asked to redeploy every service on the
   next boot, then the stack, every deployed service and the core services
   (registry mirror, mail server, tunnel, telemetry collector) are stopped.
   Swarm services are scaled to zero and containers lose their restart policy,
   so nothing comes back on the old server after a reboot. **Your sites are down
   from here** until the new server has redeployed them.
4. **Copy settings and data**: `.env` (with `AUTH_SECRET`, which every stored
   secret is encrypted with) and `homerun.yaml`, then **every named Docker
   volume** on the old server (Homerun's database, certificates and routing
   files, and every service's volumes), recreated with the same labels and
   options and streamed over SSH with file ownership kept, then every host path
   a service bind-mounts, to the same path on the new server.
5. **Install Homerun on the new server**: the same installer runs there with the
   same user, version and image, finds `.env` and the volumes already in place
   and starts on them. It becomes a swarm manager like any fresh install.
6. **Wait for Homerun** to answer on the new server. On its first boot it
   redeploys every service: images are pulled again and git services are rebuilt
   from their repositories, so a service built for a different CPU architecture
   is rebuilt for the new one.

The copy runs with Homerun stopped, so the downtime grows with the data: about
the volumes' total size divided by the old server's upload speed. Run
[Docker Cleanup](https://zedensix.com/homerun/docs/docker-cleanup) and delete the volumes you don't need first.

**A failed move can be run again** with the same command. Each finished volume
is recorded under `.move/<target>` next to the compose file, so a second run
only copies what didn't finish. Delete that directory to start a move to the
same server from scratch.

## After the move

The installer ends with a list of what's left to do by hand:

- **DNS**: point the dashboard's record, the base domain and its wildcard, and
  every custom domain at the new server. On **DNS → Domains**, change each
  domain's target to the new server's address, so
  [DNS automation](https://zedensix.com/homerun/docs/dns-automation) updates the records it manages.
- **Swarm nodes**: other machines in the old server's swarm stay joined to it.
  On each, run `docker swarm leave --force`, then add it to the new server from
  **Remote Hosts → Add a server**. A service pinned to one of them by a
  placement rule waits until it's back.
- **Build servers** keep their address and token. The new server has to reach
  them, which a machine on your home network usually isn't from a VPS.
- **A volume whose data lives outside Docker** (an NFS mount, a local volume
  with a `device` option) is recreated with the same options but not copied.
- **A Pangolin tunnel** from the old server isn't needed on a VPS with a public
  address: turn it off on **DNS → Pangolin** once DNS points at the new server.
- Containers Homerun didn't start, and Docker images on the old server, aren't
  moved.

## Going back

The old server still has everything, stopped. Start it again:

```bash
sudo docker compose -f /home/homerun/homerun/compose.yaml -f /home/homerun/homerun/compose.swarm.yaml up -d
```

It redeploys every service on its own, the same way the new server did. Once
you're happy with the new server, remove the old one's data with
`docker compose ... down --volumes` and `docker volume prune --all`.
