Hetzner Live Migration Demos: A Step‑by‑Step Guide
Introduction
Moving a running server without downtime sounds like magic – and with Hetzner’s Live Migration feature, it’s a reality. In this demo‑focused guide we walk you through the entire process, from preparation to validation, so you can migrate VMs safely and confidently.
What Is Live Migration?
Live migration copies a virtual machine’s memory, CPU state, and attached storage to a new host while the VM stays online. Hetzner’s implementation runs on the Cloud and Dedicated Root Server platforms, offering:
- Zero‑downtime for most workloads.
- Automatic network re‑attachment.
- Rollback options if something goes wrong.
Prerequisites
Technical Requirements
- Hetzner Cloud account with at least two servers in the same data centre.
- Root access (or sudo) on the source VM.
- SSH key pair for secure communication.
Best‑Practice Checklist
- Backup critical data – snapshots or external backups.
- Update the OS and kernel to the latest stable version.
- Disable SELinux/AppArmor temporarily if they interfere with migration.
- Ensure both servers have identical CPU architectures (e.g., x86_64).
Demo 1: Simple Live Migration Using the Hetzner Cloud Console
Step 1 – Create the Target Server
Log in to the Hetzner Cloud Console, select the same data centre, and spin up a new server (same size is recommended). Note the SERVER_ID of both source and target.
Step 2 – Install the Migration Helper
ssh root@source-server apt-get update && apt-get install -y qemu-guest-agent systemctl enable --now qemu-guest-agent
Repeat on the target server.
Step 3 – Trigger Migration
# Replace IDs with your own hcloud server migrate --source SERVER_ID --target TARGET_ID
The console shows progress: copying memory, syncing disks, and final switchover.
Step 4 – Verify
- Check
uptime– it should show continuous operation. - Run
pingorcurlto confirm services are reachable.
If everything looks good, you can decommission the old server.
Demo 2: Live Migration via API (Advanced)
Why Use the API?
The API allows automation, bulk migrations, and integration with CI/CD pipelines. It’s perfect for teams managing dozens of VMs.
Step‑by‑Step
# Set your API token export HCLOUD_TOKEN="your-token" # Get server IDs SOURCE=$(hcloud server list --output json | jq -r '.[] | select(.name=="source-vm") | .id') TARGET=$(hcloud server create --name target-vm --type cx31 --datacenter nbg1-dc3 --output json | jq -r '.server.id') # Initiate migration hcloud server migrate $SOURCE $TARGET
The command returns a action_id. Poll the action until it’s "finished":
while true; do STATUS=$(hcloud action get $action_id --output json | jq -r '.status') [ "$STATUS" = "running" ] && sleep 5 || break done
Post‑Migration Checks
Run a quick health‑check script on the target:
#!/bin/bash services=(nginx mysql php-fpm) for svc in "${services[@]}"; do systemctl is-active --quiet $svc && echo "$svc OK" || echo "$svc FAILED" done
Common Issues & Troubleshooting
- Network timeout – Verify both servers share the same VPC and firewall rules.
- Incompatible CPU features – Use the "migrate‑compatible" server type or enable
cpu-modelflag. - Disk sync failure – Ensure no heavy write load during migration; consider snapshotting first.
FAQ
- Is live migration supported for Windows VMs?
- Yes, but you must enable Hyper‑V integration services and use a supported Windows Server edition.
- How long does a migration take?
- Typical migrations finish in 2–5 minutes for a 20 GB VM. Larger memory footprints may take longer.
- Can I roll back if something goes wrong?
- Hetzner keeps the source VM running in a paused state until you confirm success. You can abort and revert instantly.
- Do I need to stop services?
- No, live migration is designed to keep services running, though it’s wise to quiesce databases for consistency.
Conclusion
Hetzner’s live migration feature removes the traditional hassle of server moves. Whether you prefer the graphical console or the powerful API, the steps above give you a reliable roadmap. Test the process in a non‑critical environment, follow the checklist, and you’ll enjoy seamless scaling and maintenance without compromising uptime.
Call to Action
Ready to try a live migration on your Hetzner cloud? Create a test server now and follow the demos. Need help? Contact our support team for a personalized walkthrough.
Comments are closed, but trackbacks and pingbacks are open.