Introduction
The production server migration was done, and the old server had reached the "watch it for 2–3 days, then delete" stage. On Lightsail, a stopped instance still accrues charges, so "just leave it around for a while" isn't an option — deletion is the only path. And deletion is irreversible.
This article is the checklist of what I actually did in the ~30 minutes before pressing the delete button: evacuating logs and configs, and cleaning up the origin-IP list registered with our payment provider. I also hit two shell gotchas along the way, so those are included too.
What I evacuated
What hadn't been moved to the new server wasn't the application itself — it was the "periphery":
- Apache access/error logs (25 files including rotated ones)
- 143 files from EC-CUBE's
var/log(about 7 weeks' worth) -
httpd.conf,conf.d/,php.d/, and Let's Encrypt renewal configs - crontab, the rpm package list, and
yum history
91MB in total, placed on the new server at /var/backup/old-prod-YYYYMMDD/, root-only (700).
Why keep the logs
The access statistics for the month before the migration — the ratio of scan traffic to total requests, the number of source IPs behind login attacks — were all computed from these logs. They are the only baseline for comparing "did access patterns change?" after the migration.
Same for the config snapshot. When you later wonder "this setting existed on the old server but not the new one," the snapshot is your only evidence.
# Example: capturing configs and metadata (on the old server)
rpm -qa | sort > /tmp/rpm-list.txt
yum history list all > /tmp/yum-history.txt
crontab -l > /tmp/crontab-root.txt
Gotcha 1: ssh inside a heredoc ate the rest of the script
While writing the evacuation script as a heredoc, I ran into steps silently not executing.
bash <<'EOF'
ssh old-prod 'rpm -qa' > rpm-list.txt # stdin gets consumed here
echo "next step" # never runs
EOF
The cause: ssh reads standard input. The remainder of the heredoc (the following lines) gets passed to ssh, and the script ends early. The fix is ssh -n, which detaches stdin.
ssh -n old-prod 'rpm -qa' > rpm-list.txt
Gotcha 2: bundling multiple sources into one rsync hides failures
Trying to finish the transfer in one shot, I passed several directories to a single rsync:
rsync -av old-prod:/etc/httpd/ :/var/log/httpd/ :/etc/letsencrypt/ ./backup/
This looks like it works, but when some paths fail while others succeed, the overall result is hard to judge — failures can get swallowed silently. For an evacuation, where the whole point is "everything made it," running individual rsyncs and checking each exit code was the reliable approach.
for src in /etc/httpd /var/log/httpd /etc/letsencrypt; do
rsync -av "old-prod:${src}/" "./backup${src}/" || echo "FAILED: ${src}"
done
Deletion order
Once the evacuation was done, deletion proceeded in this order:
- Take one Lightsail snapshot (billed only for actual used capacity — cheap insurance)
- Delete the instance
- Release the now-detached static IP (a static IP detached from an instance is billable)
- Remove the old IP from the origin-IP list registered with the payment provider (for both production and test environments)
- Update the asset inventory, SSH config, and ops notes with the new server's info
Skip step 4 and an unused IP stays on the payment provider's allowlist. After release, that IP gets assigned to someone else — meaning "an IP that isn't ours is registered as our payment origin." This was cleanup that belonged on deletion day itself.
Summary
- Deletion is irreversible, so the criterion isn't "what do I need in order to delete" but "what will I miss after it's gone." Logs and configs are always the latter
- Use
-nwith ssh inside heredocs — otherwise the rest of your script silently disappears - Don't bundle evacuation rsyncs; run them one at a time where exit codes are visible
- "Deletion work" includes releasing the static IP and updating the payment provider's origin list
The last command on migration day was rsync, not rm — that's this checklist in one sentence.
Top comments (0)