I bought a new server (Ubuntu 24.04, with the new domain pointed at it) and needed to move a set of services from the old server over “as-is.” Instead of typing everything by hand, I had AI (Claude Code) survey the old machine, replicate on the new machine, and finally verify byte-for-byte against the source. All three services were moved with only one hiccup — and that one wasn’t something AI could solve. This post records the pits I fell into and the verification method in full.
The essence of migration: survey → replicate → verify against the source
“Migrating a server with AI” doesn’t mean having AI generate configs out of thin air; it means making AI the operator that can “see the old machine and reach the new one.” The whole thing breaks into three steps, each with a one-line rule:
- Survey: read the current state before acting — don’t rely on memory, don’t guess.
- Replicate: copy byte-for-byte, including the files you’d assume “you’d never need.”
- Verify: compare the new machine against the old machine, not against “what you expected.”
This time the old machine was mm (hosting zhimayuandi-old.com) and the new one was oo (hosting zhimayuandi.com), both Ubuntu 24.04 x86_64, with SSH aliases configured. Three things to move: the site’s HTTPS certificate and nginx structure, a Go blog service on port 8080, and the backend feedback (bug) data.
First: HTTPS / nginx — “works locally” ≠ “works from the public internet”
The old machine had long had HTTPS via certbot. The new machine was plain HTTP: a server { listen 80 default_server; } that accepted everything. Goal: move the certificate and the “same nginx structure as the old machine” over.
Surveying, I got three key “cards”
The first thing AI did was put facts I couldn’t see with my own eyes on the table:
systemctl cat blog-cli.service # what the unit file for a service looks like
nginx -v && ls /etc/nginx/sites-enabled/
certbot --version
nslookup zhimayuandi.com # has the domain actually been pointed at the new machine?
The old machine’s HTTPS structure was a three-part layout, copied directly:
www.zhimayuandi-old.comblock on 443 →301to the apex domain;- Main domain content block listening on 443 (cert +
include options-ssl-nginx.conf+ dhparam); - One block on port 80 →
301to HTTPS when the host matches the domain, everything else404.
So the new machine followed suit: first use certbot’s nginx plugin to issue the cert (issue only, don’t touch the config):
certbot certonly --nginx -d zhimayuandi.com -d www.zhimayuandi.com
# cert lands in /etc/letsencrypt/live/zhimayuandi.com/
# auto-renewal timer is set up too
Then rewrite the nginx site config to match the old machine’s three-part layout, pass nginx -t, and reload. Everything went smoothly up to here.
The blocker: 443 unreachable from the public internet, yet fully working locally
Cert, config, and redirects were all set. Testing HTTPS locally (inside the new machine):
curl -sk -H "Host: zhimayuandi.com" https://127.0.0.1/ # → 200, all good
But accessing https://zhimayuandi.com from the public internet timed out, while port 80 redirected fine. This shows:
Working inside the server ≠ working from the public internet. There’s a “cloud boundary” in between — the Tencent Cloud lightweight server’s firewall (in the console, not on the server).
ss -tlnp clearly showed nginx listening on 0.0.0.0:443, ufw was off, and the only iptables rule on the host (YJ-FIREWALL) rejected two specific IPs. So the problem wasn’t “inside the host” — it was at the “cloud edge.” This firewall can’t be changed over SSH; a human had to open 443 in the Tencent Cloud console.
That was the only step in the whole process that needed a real person. The troubleshooting conclusion is crisp: first separate the “cloud boundary” from “inside the host” — if the loopback self-test passes, the listener is there, and the host firewall isn’t blocking, it’s probably the cloud security group/firewall not allowing the port. After opening it, HTTPS worked immediately.
Second: the Go blog service — the “single file” is actually a “three-piece set”
The user said the thing running on 8080 was “probably a single-file Go blog.” Indeed, ss -tlnp showed a 16MB Go binary blog-cli (brand: GeekBlog). But moving just the binary would have been wasted effort — survey its unit file and it’s obvious:
systemctl cat blog-cli.service
# ExecStart=/root/.local/bin/blog-cli --db ./blog.db serve
# WorkingDirectory=/root/.local/bin
WorkingDirectory=/root/.local/bin determines where the relative path --db ./blog.db actually lands, and also what the service really depends on:
/root/.local/bin/blog-cli # 16MB Go executable
/root/.local/bin/web/ # frontend: index.html / post.html / static/
/root/.local/bin/blog.db # SQLite, holding 50 posts
The “single-file service” actually eats a binary + static assets + database trio at runtime. Miss one and the service starts but the page is wrong; miss the database and you’ve moved an empty shell.
Replication was a cross-machine streaming tar, no intermediate files:
ssh mm "cd /root/.local/bin && tar -czf - blog-cli web blog.db" \
| ssh oo "mkdir -p /root/.local/bin && tar -xzf - -C /root/.local/bin"
Then write the same systemd unit over, enable --now, and the service was running on the new machine.
Third: data — for a service that reads files in real time, copying the files is the migration
The feedback (bug) service was the piece “intentionally left empty” on the new machine. The data was actually simple: the bug service stores each piece of feedback as a markdown file in /var/lib/bug/bugs/*.md. The old machine had 11; the new machine’s directory was empty — exactly what the user meant by “the old site has content, the new site doesn’t.”
Same approach: copy the 11 .md files over with a tar pipe. Because the service reads files in real time and has no central index, no restart was needed — the list page immediately showed 11 new entries.
The real payoff: four “fake bugs” and a verification method
The most valuable part of this migration isn’t the commands, but the method for judging “does this actually count as a bug?” Along the way I hit four obstacles that looked abnormal but were all illusions:
Fake bug 1: HEAD requests return 404
Probing the new machine’s blog homepage with curl -I (a HEAD request) returned 404, which I nearly treated as a problem to investigate. Compare with the old machine: the old machine also returns 404. That’s inherent blog-cli behavior — it only responds to GET on /, and HEAD falls through to the default 404.
Lesson: whether something is a bug should be judged against the source machine’s behavior, not your expectation. If the source machine behaves the same way, it’s not a regression introduced by this migration.
Fake bug 2: the list page’s “routing illusion”
The bug service’s port 8601 returned 404 when directly hitting /bugs/, yet the public URL https://…/bugs/ clearly had content. Following nginx explained it: nginx strips the /bugs/ prefix and proxies to the root path / on 8601. The real list page on 8601 is /; /bugs/ is only the external address.
Lesson: “the external path” and “the backend route” are not the same thing. When troubleshooting, don’t stare at the external URL — see which target the proxy chain actually hits after stripping the prefix.
Fake bug 3: new and old data md5 mismatch
Verifying /api/posts, the md5 of the responses downloaded from the new and old machines didn’t match. Scary — until I diffed byte-by-byte… after parsing with Python as UTF-8, the per-post JSON was completely identical. The difference came from the middle layer: PowerShell decoded curl’s output as text in the current code page, garbling the bytes.
Lesson: verify consistency on raw bytes. Let
curl -o filewrite to disk, thendiff/md5sum— don’t let the terminal, PowerShell, or encoding sit between the data.
Fake bug 4: treating “empty content” as “broken service”
The new machine’s /bugs/ page initially showed no entries, and my first reaction was that the reverse proxy was broken. Actually the data directory had 0 files — the service was fine, there was just no data. Distinguishing “200 with an empty list” from “404/500” sends troubleshooting in completely different directions.
Retrospective: a reusable “AI server migration” checklist
- Survey first, facts first:
systemctl cat <svc>,ss -tlnp,md5sum <bin>,lsthe data dirs,nslookupthe domain. Have AI lay out objective facts before talking about how to do it. - Replication = unit + executable + runtime dependencies: watch
WorkingDirectoryand relative paths; move static assets, DB, and config files too, not just the binary. - Transfer via tar + ssh pipe: no intermediate files, permissions preserved —
tar -czf -sends,tar -xzf -receives; after moving, compare sizes and hashes withmd5sum/ls -l. - Verify three layers, each against the source machine: record source behavior first → loopback self-test on the new machine → external test from the public internet; for content,
curl -oto disk and do byte-level diffs, never compare terminal text. - “Local works ≠ public works”: if loopback returns 200, the listener is up, and the host firewall isn’t blocking, it’s the cloud boundary (security group/firewall) — open it in the console; SSH can’t do it.
- Suspect bugs: compare against the source first: same behavior on the source machine = inherent behavior, don’t waste time investigating; the success criterion for a migration is “identical to the source,” not “as expected.”
- Sink knowledge as you go: back up old configs to
/root/nginx-backups/, write the deployment topology into memory/docs — the next renewal or troubleshooting will have evidence to work from.
A short epilogue
Across the whole migration, AI handled surveying, rewriting configs, issuing certificates, cross-machine transfer, and byte-level verification; the only thing requiring a human was clicking “allow” on port 443 in the cloud console. That’s probably the most comfortable division of labor in “AI ops” today: AI does everything on the server reachable over SSH; humans only do the cloud-console gate that AI can’t reach. The day consoles become operable by AI, server migration can be fully unattended.