In this tutorial
- Which signals say the instance has outgrown its plan?
- How do you pick the new plan?
- How do you prepare before the copy?
- How do you copy files between the two instances?
- What is the safe way to carry databases across?
- How do you test the new instance before DNS changes?
- How do you switch over?
- When should you destroy the old instance?
Which signals say the instance has outgrown its plan?
Move when the numbers say so for more than a day or two, not after a single spike. The signals that matter:
- Memory:
free -hshows little available and swap in steady use. - CPU: load average in
uptimestays above the vCPU count fromnproc. - Disk:
df -h /passes 80% and keeps growing. - Transfer: the Usage graphs tab shows you will pass the monthly allowance before the month ends.
The usage monitoring tutorial shows how to collect these figures. If only one resource is short, a different line may fix it more cheaply than a bigger plan in the same line.
How do you pick the new plan?
Pick the size that covers the constrained resource with room for a year of growth. For example, moving from A2-4 (2 vCPU, 4 GB RAM, 100 GB NVMe, 5 TB transfer) to A4-8 gives you 4 vCPU, 8 GB RAM, 180 GB NVMe and 6 TB of transfer for $28.80 a month. Its shortest term is 3 months, ordered from $86.40.
Staying in the same city keeps latency unchanged for your users. Moving is also a chance to change city or line; check that the plan you want is sold in that city on its plan page. Each account can hold up to 10 servers, so make sure there is a free slot for the new one while the old one still runs.
How do you prepare before the copy?
Lower the DNS TTL a day ahead so the switch takes minutes, not hours. At your DNS provider set the TTL of the A and AAAA records for example.net to 300 seconds and wait for the old TTL to run out.
Then deploy the new instance with the same image as the old one, for example Ubuntu 24.04 on both, and tick the same SSH key. Same release means the same package versions and fewer surprises. Write down the inventory of the old server:
dpkg --get-selections > ~/packages.txt
systemctl list-unit-files --state=enabled > ~/enabled.txt
sudo crontab -l > ~/root-cron.txt; crontab -l > ~/user-cron.txt
sudo ss -tulpn > ~/listening.txtCopy those files to the new server and install the same packages with sudo apt-get install.
How do you copy files between the two instances?
Use rsync over SSH, run from the new server so it pulls. Do one full pass while the old server keeps serving, then a short final pass later.
# on the new instance, as root
ssh-keygen -t ed25519 -f /root/.ssh/migrate -N ''
cat /root/.ssh/migrate.pub # add this line to /root/.ssh/authorized_keys on the old server
rsync -aHAX --numeric-ids --info=progress2 -e "ssh -i /root/.ssh/migrate" \
root@198.51.100.24:/var/www/ /var/www/
rsync -aHAX --numeric-ids -e "ssh -i /root/.ssh/migrate" \
root@198.51.100.24:/etc/caddy/ /etc/caddy/Copy application folders, configs you understand, and home directories. Do not copy /etc/fstab, network config, SSH host keys or /etc/hostname; those belong to the new machine. Traffic between the two counts toward each server's transfer like any other traffic, so a large dataset is worth compressing.
What is the safe way to carry databases across?
Dump on the old server, load on the new one, and repeat right before the switch so no writes are lost.
# PostgreSQL, streamed directly
ssh -i /root/.ssh/migrate root@198.51.100.24 "sudo -u postgres pg_dumpall" | sudo -u postgres psql
# MariaDB or MySQL
ssh -i /root/.ssh/migrate root@198.51.100.24 "mysqldump --all-databases --single-transaction --routines" | mysqlFor a busy database, put the app in maintenance mode or stop the writer service on the old server for the final dump. A few minutes of read-only time is a fair price for a clean copy.
How do you test the new instance before DNS changes?
Point only your own computer at it. Add a line to your local hosts file (/etc/hosts on Linux and macOS, C:\Windows\System32\drivers\etc\hosts on Windows) with the new address:
198.51.100.77 example.net www.example.netNow your browser reaches the new server while everyone else still reaches the old one. Click through logins, forms and uploads. If you use Caddy, certificates will not issue until DNS points at the new server, so test over HTTP or accept the warning for now. Or test without touching hosts:
curl -sI --resolve example.net:80:198.51.100.77 http://example.net/How do you switch over?
Run the final sync, then change DNS, then watch logs.
- Stop writers on the old server, for example
sudo systemctl stop php8.3-fpmor your app unit. - Run the rsync commands and the database dump again; they finish fast because only changes move.
- Update the
Arecord to the new IPv4 and theAAAArecord to the new IPv6. - Check with
dig +short example.netfrom a couple of networks. - Follow live traffic with
sudo journalctl -fu caddyon the new server.
Leave the old server running and untouched for a day or two. Requests from resolvers that cached the old address still get answers, and you have a fallback if something was missed.
When should you destroy the old instance?
Close to the end of its prepaid term, once you are sure nothing still reaches it. Destroying ends the term on the spot and unused time is not paid back, so there is no saving in destroying early, only less fallback time.
The old server will receive a renewal invoice 7 days before its term ends. Simply leave it unpaid if you are done with it; the server pauses at term end and is removed 14 days later. Before you destroy, check the access log one last time:
sudo tail -n 50 /var/log/caddy/access.log
sudo ss -tn state establishedPull any final copy you want, then use the destroy action in the console.
Questions about this tutorial
Can I upgrade a plan in place?
No. Plans keep their size for their life, so growing means deploying a larger plan and migrating, as described here.
Will my IP address move to the new server?
No. The new instance gets its own IPv4 and IPv6, which is why the DNS switch is part of the process. Update any allow lists that use the old address.
Do I get money back for the old term?
No. Unused time is not refunded, which is why the old server is best retired near the end of its term.
Can I move to another city during the upgrade?
Yes. Deploy the larger plan in the city you want, as long as that plan is sold there, and follow the same steps.
How long does the switch take?
With a low TTL set a day ahead, most visitors follow the new address within minutes. The copy itself depends on data size and transfer speed between the two cities.