Migrating from the cloud to a dedicated server
This is the practical how-to for a cloud to dedicated migration: moving a steady workload off AWS, or any cloud, onto a dedicated server you rent and run yourself. It is a playbook, not a single command, so it is organised as phases you work through in order: inventory, sizing, building the landing zone, moving the data, cutting over, and the day-2 disciplines that keep the machine healthy afterwards.
The case for leaving the cloud on cost grounds is covered separately in our dedicated server vs cloud costs guide, which has the arithmetic. This guide assumes you have already decided the numbers make sense and you want to know how to do the move without losing data or a weekend. Everything here targets Ubuntu 24.04 LTS on the new machine, and Server.Biz servers are unmanaged, so every step below is yours to run.
Why teams repatriate, and what should stay
Cloud repatriation makes sense for one specific shape of workload: something that runs 24/7 at a fairly steady utilisation. The cloud bill for that shape is dominated by always-on compute you never switch off, plus egress charged per gigabyte. Fixed-price hardware attacks exactly those two lines, and a server that is busy most of the time wastes none of the elasticity you are paying a premium for.
Be honest about what should not move. Bursty batch jobs with real idle time, anything that leans hard on a managed service you do not want to operate, and workloads that genuinely need multiple regions are better left where they are. The common end-state is not all-or-nothing: the steady layer lands on dedicated hardware, the spiky layer stays in the cloud, and the two talk over a connection you control. Repatriate the base load, not the peaks.
The rule of thumb
If a resource ran all month at moderate-to-high utilisation, it is a repatriation candidate. If it spent most of the month idle and spiked occasionally, the cloud is still doing something for you. Move the first kind, keep the second.
Inventory: list every service and its self-hosted twin
You cannot move what you have not written down. The first phase is an honest inventory of everything the application touches, because the surprises in a migration are almost never the servers, they are the managed services nobody remembered were load-bearing. Walk the architecture and list every running component, then split them into three piles: things you already run yourself, managed services with a clean self-hosted equivalent, and proprietary services that force a keep-or-replace decision.
Most managed services have a well-worn open-source counterpart that runs happily on a single box. The table maps the common ones. The last row is the one that needs a real decision before you commit to a date.
| Cloud service | Self-hosted equivalent | Effort |
|---|---|---|
| EC2 / cloud VMs | A user or container on the dedicated box | Low |
| RDS / managed Postgres | PostgreSQL you run, tune and back up | Medium |
| S3 / object storage | MinIO, or the filesystem plus backups | Medium |
| ElastiCache / managed Redis | Redis running on the box | Low |
| SQS / managed queues | Redis, or a small broker like RabbitMQ or NATS | Medium |
| Lambda / scheduled cron | systemd timers plus long-running workers | Low |
| DynamoDB, Cognito, Kinesis | Keep-or-replace decision (see below) | High |
The proprietary row is where migrations stall. A service like DynamoDB or Cognito has no drop-in local twin, so you have three options: keep calling it from the dedicated box over the public internet, replace it with something self-hosted and rewrite the code that talks to it, or leave the part of the app that depends on it in the cloud entirely. Make that call per service, in writing, before you size anything. A workload that is 90% portable and 10% welded to a proprietary API is a hybrid, and that is fine, as long as you decided it on purpose.
Sizing the target from real utilisation
Do not size the new server from the instance types you happened to rent. Cloud instances are usually over-provisioned, because scaling up is a slider and nobody goes back down. Size from what the workload actually used. Pull the real numbers out of your cloud monitoring: peak and 95th-percentile CPU across the fleet, resident memory in use rather than allocated, and the storage IOPS and throughput your volumes really sustained. Those three figures, summed across every instance you are folding onto one box, are your true requirement.
Add headroom on top of the peak, not the average, so a busy hour does not become an incident. A useful default is 20-30% above the observed peak for CPU and memory, and enough NVMe to cover your IOPS figure with room to grow. A single modern dedicated box consolidates a surprising number of small cloud instances, because you stop paying the hypervisor and noisy-neighbour tax and get the whole CPU. Match cores, RAM and disk to the summed real usage plus headroom, then open the live catalog and pick the closest configuration.
The delivery times above are the platform's: instant configurations are typically online in around two hours, custom builds in about a day. That matters for the plan, because it means you can have the target machine racked and reachable while you are still rehearsing the data move, rather than waiting on hardware at the last minute. Order early, build the landing zone in parallel.
Build the landing zone before the data arrives
Never migrate production data onto a machine that is not yet hardened, monitored and backed up. Stand up the full landing zone first, verify it, then move data into it. This is the phase where the getting-your-server-online guide does the heavy lifting; do not repeat it, do it. The steps below are the order to build in.
-
Harden the base
Change the delivered root password, create your admin user, install SSH keys, disable password login, and default-deny the host firewall. A dedicated server has no cloud security group in front of it, so the host firewall is the entire perimeter, IPv6 included. The getting-your-server-online guide is the checklist.
-
Lay down the runtime
Most applications land cleanly on a container host. Our production Docker host guide is the common target shape: Docker Engine, a reverse proxy terminating TLS, and your services as containers. If you run bare processes instead, install the runtimes and set up systemd units.
-
Stand up the database
Install and tune PostgreSQL, MySQL or MariaDB on the box before any data lands, following the production database server guide for memory settings, the storage layout and connection limits. An untuned default database will disappoint you under real load.
-
Get backups running first
Configure and test the backup job while the machine is still empty, so the very first production data written is already protected. The server backup strategy guide covers restic to a second server and a tested restore. Backups before production data, not after.
-
Rehearse a restore
Restore one file and one throwaway database from the fresh backup before you trust it with anything real. An untested backup is a hope, not a backup.
Migrating databases: rehearse, then cut over
The database is the part of a cloud to dedicated migration that decides your downtime, so it gets two passes: a rehearsal that costs nothing and tells you the timings, then the real cutover using those timings. Start with the rehearsal. Dump the live cloud database over the network to the new box and restore it locally, timing both, while production keeps running untouched. This proves the pipe works and gives you a real number for the maintenance window.
Rehearsal dump from the managed database. OLD_DB_HOST is your RDS or cloud Postgres endpoint; the custom format (-Fc) is compressed and restores in parallel. time reports how long it took.
time pg_dump -Fc -h OLD_DB_HOST -U myuser -d mydb -f mydb.dump
Restore into the local PostgreSQL and time that too. The -j 4 flag restores four tables at once; raise it toward your core count on a big database. Add up the two timings: that is your rehearsal cutover cost.
sudo -u postgres createdb mydb
time pg_restore -j 4 -d mydb mydb.dump
If dump plus restore is a few minutes, a maintenance window is the simplest correct answer and you can stop here. If it runs to hours because the database is large, use logical replication instead: replicate the cloud database to the new one live, let it catch up over days, and cut over in seconds once it is in sync. The mechanics are a publication on the source and a subscription on the target.
The low-downtime paths, side by side
For a large database, logical replication turns hours of downtime into seconds. Create a publication on the cloud database, then a subscription on the new one, and let it copy the existing data and stream changes until the two are level. Managed Postgres usually supports this with a configuration flag you enable on the source.
On the cloud (source) database, publish the tables you are moving.
CREATE PUBLICATION migration FOR ALL TABLES;
On the new (target) database, subscribe to it. It copies the current data, then streams changes until it is caught up. Watch pg_stat_subscription until the lag is near zero.
CREATE SUBSCRIPTION migration
CONNECTION 'host=OLD_DB_HOST dbname=mydb user=myuser password=SECRET'
PUBLICATION migration;
When replication is in sync, the maintenance window is short. This is the copy-paste runbook: stop writes, do a final sync, repoint, verify. With replication already level, the window is seconds. With a plain dump instead, swap steps 2 and 3 for the pg_dump and pg_restore above, and the window is your rehearsal timing.
# 1. Put the application into maintenance mode so it stops writing
# (scale the web tier to zero, or flip a read-only flag)
# 2. Let logical replication drain the last transactions, then
# check the target has caught up (lag ~ 0)
sudo -u postgres psql -d mydb -c "SELECT * FROM pg_stat_subscription;"
# 3. Reset the target sequences and drop the subscription so the
# new database owns its data outright
sudo -u postgres psql -d mydb -c "DROP SUBSCRIPTION migration;"
# 4. Point the application config at the new database host,
# start it, and run a smoke test (login, one read, one write)
# 5. Confirm writes land on the new box, then leave maintenance mode
Your downtime estimate is not a guess: it is the sum of the steps that happen inside the window. With a final dump that is dump time plus restore time plus smoke-test time, all of which you measured in the rehearsal. With logical replication it is drain plus smoke test, usually under a minute. Measure it once on a rehearsal copy and you can tell the business a real number before you schedule the window.
Migrating files and objects
Files split into two jobs: things on a filesystem, which rsync moves, and things in an object store like S3, which rclone moves. Both support a first bulk pass while production is live and a fast delta pass during the window, so you copy terabytes ahead of time and only the last changes at cutover.
For filesystem data, rsync over SSH with resume flags is the tool. Run it once now to move the bulk, then again inside the maintenance window to catch what changed. The second run only transfers the delta, so it is quick.
Bulk copy uploads from the old host. The archive flags preserve permissions and ownership; --partial resumes a dropped transfer instead of starting over. Run this again during the window for a fast delta sync.
rsync -aHAX --partial --info=progress2 \
-e ssh user@OLD_HOST:/var/www/uploads/ /srv/uploads/
For an S3 bucket, configure rclone once with a remote named awsprod. Substitute your keys and the region the bucket lives in. This file goes at ~/.config/rclone/rclone.conf.
[awsprod]
type = s3
provider = AWS
access_key_id = YOUR_ACCESS_KEY
secret_access_key = YOUR_SECRET_KEY
region = eu-west-1
Sync the bucket down to local storage on the new box, then verify every object by checksum. The check pass is not optional: it is how you know the copy is byte-for-byte correct before you delete anything in the cloud.
rclone sync awsprod:my-prod-bucket /srv/objects/my-prod-bucket \
--transfers 16 --checkers 32 --fast-list --progress
rclone check awsprod:my-prod-bucket /srv/objects/my-prod-bucket --one-way
Estimate the egress bill before you start
Getting data out of a cloud is the one big one-time cost of leaving it. Egress is billed per gigabyte, and a large object store or database can run to a real invoice on the way out. Estimate it first: total the gigabytes you will pull, multiply by the provider's per-gigabyte egress rate, and you have the number before it surprises you. It is a one-off, and it ends the moment the migration does, but plan for it rather than discovering it.
If your application expects an S3 API rather than a filesystem, point it at a local MinIO server instead of AWS and sync into that. The application keeps talking S3, the bytes just live on your box.
Cutover: DNS, parallel run and rollback
Cutover is a traffic switch, and DNS is the switch. The one preparation that saves you here happens days ahead: lower the time-to-live on the records you will move so that when you flip them, clients pick up the change in minutes instead of hanging onto the old address for hours. Set the TTL to 300 seconds several days before the cutover, because the old, long TTL has to expire from every resolver first.
Days before cutover: lower the TTL on the records you are moving. The value is in seconds, so 300 is five minutes. Do this early, because the change only helps once the previous TTL has aged out everywhere.
; lower TTL to 300s several days ahead of the switch
www 300 IN A 203.0.113.10
www 300 IN AAAA 2001:db8::10
At cutover: point the same records at the new server. With the TTL already at 300, traffic drains to the new box within minutes. Keep the old environment running.
; cutover: repoint to the dedicated server's addresses
www 300 IN A 198.51.100.20
www 300 IN AAAA 2001:db8::20
Before you flip DNS, run in parallel. Keep the old stack up but put it in read-only mode, or have the new box proxy a few requests, so you can exercise the new environment against real traffic without committing to it. When you do switch, watch your error rate and latency in the minutes that follow, not the hours, because a bad cutover shows up fast. And keep the rollback in your pocket: because the old environment is still running and DNS is the only thing that changed, rolling back is repointing the records to the old addresses. Do not delete or cancel the cloud environment on cutover day. Pause it, keep it for a couple of weeks until you are confident, and only then tear it down.
After the move: the day-2 disciplines
The cloud did some things quietly on your behalf: patching the host, replacing dead hardware, watching for failures. On a dedicated server those become your disciplines, and they are not hard, they just have to actually happen. Put each one on a schedule, not a good intention.
-
Patch on a cadence
Enable unattended security updates, and set a recurring window to apply the rest and reboot into new kernels. An unpatched box is the most common way a good server becomes an incident.
-
Monitor everything that matters
You no longer get a cloud dashboard for free. Run a node exporter and a Prometheus plus Grafana stack, or any agent you already trust, and alert on CPU, memory, disk fill, and RAID array state. Five minutes of setup buys weeks of warning.
-
Keep backups tested
The backup job from the landing-zone phase is running. Now prove it monthly: restore a file and a database into a scratch location and check them. A backup you have never restored is not yet a backup.
-
Watch capacity
A fixed box does not autoscale, which is the point, but it means you watch the trend. Track utilisation over weeks so you plan an upgrade before you hit the ceiling, rather than discovering it at peak.
-
Know your recovery path
When the network config is wrong and you are locked out, you can still reboot or reinstall the server from the customer portal, and access to the management console is on request, through support. Confirm that your restore runbook works on a clean machine, so a bad day is a procedure, not a panic.
A worked example: one SaaS on one box
Picture a typical small SaaS running in the cloud: a horizontally scaled web tier on several small instances, a managed Postgres database, a managed Redis for sessions and a job queue, and user-uploaded assets in an S3 bucket. It runs around the clock at steady load, and the bill is mostly always-on compute plus the egress from serving those assets. That is a textbook repatriation candidate.
The inventory maps cleanly. The web instances become containers on one strong dedicated box behind a reverse proxy. Managed Postgres becomes PostgreSQL on that same box, tuned for its RAM. Managed Redis becomes a Redis container doing both sessions and the queue. The S3 assets move to a local MinIO server so the application keeps its S3 API while the bytes live on local NVMe. A second, cheaper storage server in a different rack becomes the restic backup target, running nightly from the first night.
The move runs in order: order both machines, build and harden the landing zone, get backups green while it is empty, rehearse the database dump for a timing, bulk-sync the S3 assets with rclone and the uploads with rsync, then pick a quiet window to do a final sync and flip DNS. The old cloud stack stays paused for two weeks as the rollback. What was a sprawling, elastic bill for a workload that never actually flexed becomes one busy box, one backup target, and a fixed monthly cost.
Cutover-readiness checklist
Do not flip DNS until every line here is true. Each row pairs a thing that must be ready with the proof that it actually is, so readiness is something you verified, not something you assumed.
| Thing | Proof it is ready |
|---|---|
| Landing zone hardened | Firewall default-denies, SSH is key-only, admin user works |
| Backups running | A restore of one file and one database has succeeded |
| Database migration timed | A rehearsal dump and restore gave you a real window figure |
| Files copied and verified | rsync and rclone check both report no differences |
| DNS TTL lowered | Records have been at 300s for longer than the old TTL |
| Rollback ready | The old environment still runs and you can repoint to it |
| Smoke test written | One login, one read, one write you can run in a minute |
When you are ready to size the target
Once the inventory and the real utilisation numbers are in hand, the live catalog has the configurations to match them, and how ordering works walks through delivery and setup. Order the target early, because the platform delivery times mean you can build the landing zone while the old stack still serves. Everything else in this playbook is yours to run on your own schedule.
