Skip to content

Prepare

Before anything is built: one 1Password vault that will hold every secret, an inventory of what runs today, and a backup of each service you want to restore. Nothing in this chapter changes the running house. Do it on the computer you use today.

2.1 Install 1Password and its command line tool

Section titled “2.1 Install 1Password and its command line tool”

Why. Every secret in this guide is created in 1Password and read from it by op, so no password is ever typed into a file in the repository.

Mac

Terminal window
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" # skip if brew exists
brew install --cask 1password 1password-cli

Open 1Password, sign in, then in Settings > Developer turn on Integrate with 1Password CLI and Use the SSH agent. In Settings > Security turn on Touch ID.

Verify. op whoami prints your account after one Touch ID prompt.

Rollback. brew uninstall --cask 1password-cli 1password.

Why. A dedicated vault keeps infrastructure secrets apart from personal logins, and its name is part of every op:// reference in this repository.

Mac

Terminal window
op vault create Infrastructure

Verify. op vault list shows Infrastructure.

Rollback. op vault delete Infrastructure (only while it is empty).

Why. Generating them now means every later step can read a secret that already exists. Disk passphrases use letters and digits only, so they type correctly on a serial console whatever the keyboard layout.

Mac

Terminal window
for vm in home infra standby; do
op item create --vault Infrastructure --category password --title "LUKS $vm" \
--generate-password='letters,digits,40' >/dev/null
op item create --vault Infrastructure --category login --title "VM $vm user" \
username=admin --generate-password='letters,digits,24' >/dev/null
done
for t in "Samba config share" "Grafana admin" "AdGuard Home admin" "MQTT homeassistant" \
"NAS backup user" "Time Machine encryption" "Scrypted admin" "restic standby repository" \
"restic home" "restic infra" "NAS Hyper Backup encryption" \
"ansible-vault warm-standby"; do
op item create --vault Infrastructure --category password --title "$t" \
--generate-password='letters,digits,32' >/dev/null
done

Insights Plus needs three values that depend on each other:

Terminal window
SECRET_KEY=$(openssl rand -hex 32)
PG_PASS=$(openssl rand -hex 24)
PROXY_TOKEN=$(printf 'proxy-auth' | openssl dgst -sha256 -hmac "$SECRET_KEY" | awk '{print $NF}')
op item create --vault Infrastructure --category password --title "Insights Plus" \
"secret key[password]=$SECRET_KEY" "postgres password[password]=$PG_PASS" \
"proxy token[password]=$PROXY_TOKEN" >/dev/null
unset SECRET_KEY PG_PASS PROXY_TOKEN

Verify. op item list --vault Infrastructure --format json | grep -c '"title"' prints 16, and op read "op://Infrastructure/LUKS home/password" | wc -c prints 41.

Rollback. op item delete "<title>" --vault Infrastructure for any item.

Why. The private key never touches the disk. 1Password’s SSH agent answers for it after a Touch ID, which satisfies “every key in 1Password”.

Mac

Terminal window
op item create --vault Infrastructure --category ssh-key --title "SSH mac-admin" --ssh-generate-key ed25519
mkdir -p ~/.ssh && chmod 700 ~/.ssh
cat >> ~/.ssh/config <<'EOF'
Host *
IdentityAgent "~/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock"
Host home
HostName 10.0.5.2
User admin
Host infra
HostName 10.0.2.5
User admin
Host standby
HostName 10.0.6.2
User admin
EOF
chmod 600 ~/.ssh/config

Verify. ssh-add -l (with SSH_AUTH_SOCK pointed at the agent socket, or simply ssh -G home | grep -i identityagent) shows the 1Password socket, and op read "op://Infrastructure/SSH mac-admin/public key" prints a line starting with ssh-ed25519.

Rollback. Remove the block from ~/.ssh/config and delete the item.

These are created by later steps, when the account or key exists. The item titles and field names matter: vm/*/.env.tpl reads them by name.

Item title Fields Created in
Mac login password 4.1
FileVault recovery key password 4.2
UniFi owner account username, password, one-time password exists today
UniFi local admin unpoller username, password 3.6
UniFi local admin protect username, password 3.6
UniFi API key insights credential 3.6
WireGuard admin VPN laptop, WireGuard admin VPN phone the client configuration files 10.11
GoDaddy username, password exists today
Cloudflare account username, password, one-time password 9.1
Cloudflare tunnel home credential 9.3
Home Assistant admin username, password, one-time password chapter 7
NAS admin username, password, one-time password exists today
NAS SNMPv3 username, auth password, priv password 11.9
MaxMind GeoLite2 account id, license key 6.3
AbuseIPDB credential 6.3
Insights Plus admin username, password 6.17
Home Assistant backup encryption key password 12.2
Remote site decisions secure note 13.1
Site-to-site VPN remote site password 13.15
Telegram bot warm-standby credential, chat id 14.4
Remote site NUT monitor password (given by the remote owner) 14.5
Remote site stack env secure note (given by the remote owner, includes their tunnel token) 14.5

Why. The restore paths need exact versions and names, and the rollback of every later chapter is “put it back as it was”, which needs a record of how it was.

Mac (the one that hosts the Home Assistant VM today), with the NAS share mounted at /Volumes/docker and the HA share at /Volumes/config:

Terminal window
mkdir -p ~/infra-migration && cd ~/infra-migration
$U list > utm-vms.txt
cat /Volumes/config/.HA_VERSION > ha-version.txt
ssh admin@10.0.5.20 'docker ps --format "{{.Names}}\t{{.Image}}\t{{.Status}}"' > home-vm-containers.txt
ssh admin@10.0.5.20 'cat /etc/network/interfaces; ip -br addr; ip -6 route' > home-vm-network.txt
ls /Volumes/docker > nas-docker-folders.txt

Then by hand, in the same folder:

  • In Synology Container Manager > Container, screenshot the list (name, image, status) as nas-containers.png. For each container that has no compose file (Scrypted, Mosquitto, Pi-hole, dnscrypt-proxy, homepage, Uptime Kuma), open Settings and screenshot the volume, port and environment tabs.
  • In UniFi, Settings > Networks: screenshot each network’s DHCP range and DNS server. Client Devices: export or screenshot every fixed IP.
  • Note every device that has 10.0.2.2 typed in by hand as its DNS server, and every MQTT client that points at the NAS.
  • The remote spoke on the SD-WAN (10.1.1.0/24) resolves names through the Pi-hole at 10.0.2.2 today. Note it: step 6.11 moves it to the new resolver.

Verify. cat ha-version.txt prints a version such as 2026.11.2, and home-vm-containers.txt lists homeassistant and matter-server.

Rollback. None needed, read only.

Skip any backup whose service you will build from scratch. Keep everything in ~/infra-migration/backups and copy that folder to an external disk when the chapter is done.

Why. Chapters 3 and 10 change the network. One file restores the whole controller.

UniFi Settings > System > Backups (UniFi OS: Settings > Control Plane > Backups): click Download. Save it as backups/unifi-before.unf.

Verify. The file exists and is larger than 1 MB.

Rollback. None needed.

Why. A full backup restores configuration, integrations, history and the HomeKit Bridge pairing. The folder copy is the second net, and it is the form the restore path in chapter 7 uses.

Mac

  1. In Home Assistant, Settings > System > Backups > Create backup (full). Download it to backups/.
  2. Copy the folders, owners and permissions kept:
Terminal window
mkdir -p ~/infra-migration/backups && cd ~/infra-migration/backups
ssh admin@10.0.5.20 'sudo tar -czpf - -C /srv/homeassistant config' > ha-config.tgz
ssh admin@10.0.5.20 'sudo tar -czpf - -C /srv/matter data' > matter-data.tgz

The Matter archive is taken while the server runs, which is good enough as a safety copy. Chapter 7 takes the final one with the containers stopped.

Verify. tar -tzf ha-config.tgz | grep -c -E 'config/(configuration.yaml|\.storage/core.config_entries)$' prints 2, and tar -tzf matter-data.tgz | head lists files.

Rollback. None needed.

2.9 The Home Assistant VM itself, for the move

Section titled “2.9 The Home Assistant VM itself, for the move”

Why. R3: if moving the VM is simple, move it. A UTM VM is one bundle, so it is. Do this step last, just before chapter 7, because the house has no Home Assistant while the VM is stopped.

Mac (old)

Terminal window
$U stop "<name from utm-vms.txt>" --request # wait until `$U status` says stopped
ls -d ~/Library/Containers/com.utmapp.UTM/Data/Documents/*.utm

Copy the .utm bundle to the new Mac over AirDrop, a shared folder or an external disk. Do the same for the infra VM if you want to move it instead of rebuilding it.

Verify. du -sh of the bundle on both Macs gives the same size.

Rollback. $U start "<name>" on the old Mac. Nothing was changed inside the VM.

Why. Scrypted’s backup carries the HomeKit pairing of every camera, so the cameras reappear in the Home app without being paired again.

  1. In the Scrypted web interface on the NAS, Settings > Backup: download the file to backups/scrypted-backup.zip.
  2. Second net, with the container stopped for a minute in Container Manager:
Terminal window
tar -czf ~/infra-migration/backups/scrypted-volume.tgz -C /Volumes/docker scrypted
  1. Write down each camera’s name and whether it records with HomeKit Secure Video today.

Verify. Both files exist. tar -tzf scrypted-volume.tgz | grep scrypted.db finds the database.

Rollback. Start the container again. Nothing changed.

Why. The password file holds the broker’s users. Restoring it means no MQTT client needs a new password.

Mac

Terminal window
cd ~/infra-migration/backups
tar -czf mosquitto.tgz -C /Volumes/docker mosquitto

Verify. tar -tzf mosquitto.tgz | grep -E 'password_file|mosquitto.conf' lists both.

Rollback. None needed.

Why. AdGuard Home starts empty. The blocklists, allowlist and local records come from Pi-hole’s export.

  1. In Pi-hole, Settings > Teleporter > Export. Save as backups/pihole-teleporter.zip.
  2. Copy the upstream configuration: cp /Volumes/docker/dnscrypt-proxy/dnscrypt-proxy.toml ~/infra-migration/backups/.

Verify. unzip -l pihole-teleporter.zip lists etc/pihole/gravity.db or adlist.json.

Rollback. None needed.

Why. The Prometheus configuration and health rules are already versioned in this repository. Only the Grafana dashboards and the secrets file live outside it.

Mac

Terminal window
cd ~/infra-migration/backups
cp /Volumes/docker/monitoring/.env monitoring.env && chmod 600 monitoring.env
cd $INFRA && scripts/sync-from-live.sh && git status --short

In Grafana on the NAS (http://10.0.2.2:3002), open each dashboard, Share > Export > Save to file, into backups/grafana/. Then move the secrets into 1Password and delete the copy:

Terminal window
set -a; . ~/infra-migration/backups/monitoring.env; set +a
op item create --vault Infrastructure --category login --title "UniFi local admin unpoller" \
"username=$UNIFI_USER" "password=$UNIFI_PASSWORD" >/dev/null
op item create --vault Infrastructure --category password --title "NAS SNMPv3" \
"username[text]=$SNMP_USER" "auth password[password]=$SNMP_AUTH_PASSWORD" \
"priv password[password]=$SNMP_PRIV_PASSWORD" >/dev/null
rm ~/infra-migration/backups/monitoring.env

Verify. git status --short in the repository shows no unexpected change (the versioned copies match the NAS), op read "op://Infrastructure/NAS SNMPv3/username" prints the SNMP user, and backups/grafana/ holds one JSON file per dashboard.

Rollback. None needed.

Why. Until the new setup has its own backups (chapter 12), this folder is the only copy of several things.

Copy ~/infra-migration to an external disk, and attach unifi-before.unf and the Home Assistant backup to a 1Password item named Migration backups if they fit (100 MB per file).

Verify. The external disk holds the folder with the same file count: find ~/infra-migration -type f | wc -l on both.

Rollback. None needed.

Item Why Where
10G SFP+ DAC cable, 0.5 to 1 m Uplink between the UDM Pro and the switch (step 3.2) For example UACC-DAC-SFP10
UTM Runs the VMs mac.getutm.app
Debian 13 arm64 netinst ISO Base of all three VMs debian.org/distrib/netinst
A UPS for the Mac, UDM Pro and switch With FileVault on, the VMs stay down after a power cut until you log in (chapter 15). A UPS rides through most cuts Hardware
A Mac with enough memory The three VMs reserve 12 GB (4 GB each). 24 GB or more leaves the workstation comfortable