Migrating a website to a VPS is a planned cutover, not a file copy. You build the new server, copy the site and the database, test on the new IP, then change DNS and keep the old host ready for rollback. This guide covers a typical Linux site, such as a PHP application or WordPress, moving from shared hosting or another VPS with rsync, a database dump and a DNS change. It is not an enterprise cloud-estate program, and it does not rank providers.
Work from a sudo account on the new VPS, and keep a way into the old host until the new site has served real traffic. Take a backup you can restore before you touch production data. The VPS backup and restore guide is the place to start if you do not already have an off-host copy.
What you are moving
| Item | Why it matters | Typical method |
|---|---|---|
| Site files | Application code, uploads and configuration | rsync over SSH |
| Database | The live content; a stale dump means lost posts or orders | mysqldump or the equivalent, then a final sync near cutover |
| DNS | Sends visitors to the new IP | Lower the TTL first, then change the A and AAAA records |
| TLS certificates | HTTPS must work on the new host after DNS moves | Issue a new certificate on the VPS after the name points there, or use a temporary name for testing |
| Cron, mail and scheduled jobs | Easy to forget, and easy to run twice during overlap | Inventory first, enable on the new host only after cutover |
If mail or a control panel lives on the same old server, treat those as separate moves. Changing a website A record does not move MX, and a half-moved mailbox is a worse outage than a late website cutover.
Step 1: inventory the old site and lower the DNS TTL
On the old host, write down the document root, the PHP version, the database name and user, cron entries, SSL details, and any non-obvious services such as Redis or a search indexer. Export a list of installed packages if you have shell access. Confirm you can still log in, and that you can create a database dump.
At the DNS host, look at the current TTL for the website records. If it is 24 hours or more, lower it to 300 or 600 seconds at least a day before the move, then wait for the old TTL to expire. Cutover is much less painful when resolvers are already willing to pick up a new IP in minutes. Leave MX, TXT and other records alone unless you intend to move those too.
Step 2: build a working baseline on the new VPS
Provision the VPS in a region close to your users, deploy a supported Linux image, and do the first-week hardening before you copy the site: a sudo user, updates, SSH keys and a firewall that allows 22, 80 and 443. The VPS setup guide and the VPS security checklist cover that baseline.
Install the web stack the site actually needs, matching major versions as closely as you can: Nginx or Apache, PHP-FPM, and MySQL or MariaDB. The Linux VPS website guide walks through Nginx, a server block and HTTPS. Create an empty site directory and a database now, so the later import has somewhere to land.
If SSH to the new VPS fails, stop and fix that first. The SSH connection refused guide is more useful than improvising firewall rules in the middle of a migration.
Step 3: copy files with rsync
From a machine that can reach both hosts, or from the new VPS if the old host allows inbound SSH, copy the document root. A dry run first is worth the minute it takes:
rsync -aHAv --dry-run --numeric-ids --exclude '.git/' \
user@OLD_HOST:/var/www/example.com/ /var/www/example.com/
rsync -aHAv --numeric-ids --exclude '.git/' \
user@OLD_HOST:/var/www/example.com/ /var/www/example.com/
Adjust the paths to match the real document roots. -a preserves permissions and timestamps, -H keeps hard links, and a trailing slash on the source matters. Check the new files, then fix ownership so the web server user can read them, and write to upload directories only where the application must write.
Do not copy caches, old backups or node_modules you can rebuild, unless the application depends on them. Do copy .env or wp-config.php, then edit the new host, database name and any hard-coded old paths or URLs before you point DNS at the VPS.
Step 4: move the database and test before DNS
Take a dump on the old host and import it on the VPS. For MySQL or MariaDB:
# on the old host
mysqldump --single-transaction --routines --triggers -u OLDUSER -p OLDDB > site.sql
# copy the file, then on the VPS
mysql -u NEWUSER -p NEWDB < site.sql
If the import fails, stop and fix that before cutover. The MySQL connection errors guide covers the usual client codes. After the import, test the site against the VPS IP. A practical method is a temporary server block, or an entry in your local /etc/hosts that points the domain at the new IP, so you can browse with the real hostname while the public DNS still points at the old host.
# on your laptop only, for testing
NEW_IP example.com www.example.com
Walk the important paths: the homepage, a login, a search, a form, and a file upload if the site has one. Check the logs while you do it. Fix URL or path mistakes on the VPS now, not after the world arrives. If the application stores the old domain inside a database, update it with the tool it supports. For WordPress, a serialized-safe search-and-replace is safer than a blind sed over the SQL dump, which can break PHP serialized strings. Change one class of URL at a time, then reload the test site.
Step 5: cut over, issue TLS, and keep a rollback window
Schedule a short window. Run a final rsync and a final database dump so the new host is current, then change the A and AAAA records to the VPS IP. Put the old site in a brief maintenance mode first if you cannot accept a few minutes of writes being lost.
Once public DNS hits the VPS, issue the certificate with Certbot or your usual tool, reload Nginx, and confirm HTTPS from a network that is not using your test hosts file. Remove that test entry so you see what everyone else sees.
Leave the old host running, but disable write-heavy cron jobs there so you do not process payments or newsletters twice. Watch the new logs for a few hours, then a day. Only after the site is stable should you raise the TTL again and, later, cancel the old hosting. If you have to roll back, point DNS at the old IP and accept that any new data written only on the VPS will need to be copied back.
Frequently asked questions
How long should I lower the TTL?
Lower it at least one old-TTL period before the move. If the old TTL was 24 hours, change it a day ahead. If you forget, cutover still works, but some visitors will keep hitting the old IP until their cache expires.
Can I migrate without downtime?
You can get close by testing first, lowering the TTL, and doing a final data sync just before the DNS change. You cannot guarantee zero lost writes if people keep using the old database during that last sync. A short maintenance flag is the honest approach for a store or a membership site.
What if the old host only gives me FTP?
Use lftp or another FTP-capable tool for the files, and phpMyAdmin or the panel’s export for the database. The cutover plan stays the same. If you can, ask the old host for SSH, because rsync is easier to repeat safely.
Should I change the PHP or database version during the move?
Prefer to match the old major versions for the first cutover, then upgrade later on the VPS. A migration plus a language upgrade is two failures in the same window.
Do I need to move email at the same time?
Only if mail actually lives on the old website host. Check the MX records. If mail is at a separate provider, leave it alone and move only the website records.