India English
Kenya English
United Kingdom English
South Africa English
Nigeria English
United States English
United States Español
Indonesia English
Bangladesh English
Egypt العربية
Tanzania English
Ethiopia English
Uganda English
Congo - Kinshasa English
Ghana English
Côte d’Ivoire English
Zambia English
Cameroon English
Rwanda English
Germany Deutsch
France Français
Spain Català
Spain Español
Italy Italiano
Russia Русский
Japan English
Brazil Português
Brazil Português
Mexico Español
Philippines English
Pakistan English
Türkiye Türkçe
Vietnam English
Thailand English
South Korea English
Australia English
China 中文
Canada English
Canada Français
Somalia English
Netherlands Nederlands

How to Migrate a VPS to Another Provider

For you to migrate a VPS to another provider, you have to back up your existing server, prepare a new VPS, transfer your files and databases, and update your domain’s DNS records.

Testing the new server before switching traffic helps prevent data loss and unnecessary downtime.

You may want to move because of high hosting costs, poor performance, limited resources, or unreliable support.

Whatever the reason, proper planning helps you move your applications without rebuilding everything from scratch.

Let’s go through the entire process in steps.

Steps to Migrate a VPS to Another Provider

Follow these steps to move your applications and data to a new Linux VPS. Some commands may differ depending on your operating system and software.

Step 1: Back Up and Audit Your Existing VPS

Create a complete backup before making changes to your existing server. This gives you a recovery option if something goes wrong during the migration.

Include the following in your backup:

  • Website files, application files, and uploaded media.
  • MySQL, MariaDB, or PostgreSQL databases.
  • Web server and application configuration files.
  • Email accounts and mail data, if hosted on the VPS.
  • SSL certificates, cron jobs, and scheduled tasks.
  • User accounts, SSH keys, and other important settings.

How to back up your VPS

To back up these items on a Linux VPS, connect through SSH and run the following commands on your old server.

1) Create a backup directory:

mkdir -p ~/migration-backup

2) Back up your website files and uploads:

tar -czvf ~/migration-backup/website-files.tar.gz /var/www

This creates a compressed archive of the files stored in /var/www. Adjust the path if your websites are stored elsewhere.

Migrate a VPS: Backup

3) Back up your databases:

For MySQL or MariaDB, export all databases into a single file:

mysqldump -u root -p --all-databases --single-transaction > ~/migration-backup/all-databases.sql

For PostgreSQL, use:

sudo -u postgres pg_dumpall > ~/migration-backup/all-databases.sql

4) Back up configuration files and SSL certificates:

sudo tar -czvf ~/migration-backup/config-files.tar.gz /etc/nginx /etc/apache2 /etc/letsencrypt

The paths depend on your server setup. Apache configuration files are stored in /etc/httpd on CentOS and AlmaLinux, so adjust the command to match your environment. If you use Nginx, you can omit the Apache directory, and vice versa.

5) Save your cron jobs and mail data:

crontab -l > ~/migration-backup/crontab.txt

If email is hosted on your VPS, also back up your mail directories. These are commonly stored in /var/vmail or individual users’ Maildir folders, depending on the mail server.

6) Copy your backups off the old VPS:

Run the following command from your local computer to download the backup folder:

scp -r USER@OLD_SERVER_IP:~/migration-backup ./migration-backup

Replace USER and OLD_SERVER_IP with your actual username and server IP address.

How to Verify the Backups

List the contents of your archives using:

tar -tzf website-files.tar.gz

Also, check that your SQL backup completed successfully and that the file is not empty. For database dumps that include a completion marker, confirm that it is present. A backup that has not been checked may fail when you need it.

Store your backups outside the old VPS. If your hosting provider offers snapshots, you can create one as an additional recovery option.

Before moving on, record your current server’s operating system, software versions, firewall rules, running services, and any external integrations that depend on its IP address.

The following commands can help:

cat /etc/os-release
php -v
mysql --version
sudo ufw status verbose

Step 2: Set Up the New VPS

Choose a VPS with sufficient CPU, RAM, storage, and bandwidth for your applications. If your current server struggles with its workload, consider upgrading the resources during the move.

Migrate a VPS: VPS Hosting Plans

Before transferring data:

  1. Provision the new VPS and connect through SSH.
  2. Update the operating system and install security patches.
  3. Install the required web server, database software, programming languages, and application dependencies.
  4. Configure users, SSH access, and firewall rules.
  5. Check compatibility with your existing software versions.

Keep the new environment as close as possible to the old one. Differences in operating systems, software versions, or server settings can cause compatibility problems.

Step 3: Transfer Files and Databases

Once the new VPS is ready, start transferring your website files, application data, and databases.

For website files, you can use tools such as rsync or scp. For example:

rsync -avz /path/to/website/ USER@NEW_SERVER_IP:/path/to/website/

This command copies files from the specified directory on your local machine to the new VPS. If you run it from the old server, the source directory will be on that server. Adjust the command accordingly.

For MySQL or MariaDB databases, export the database on the old server:

mysqldump -u DB_USER -p DB_NAME > database-backup.sql

Transfer the backup file to the new VPS and import it into the destination database:

mysql -u DB_USER -p DB_NAME < database-backup.sql

Replace the example paths, usernames, and database names with your actual details.

If your website is still receiving traffic, database records and uploaded files may continue changing during the initial transfer. Plan a final synchronization before switching traffic so recent updates are not lost.

Step 4: Reconfigure Applications and Services

Transferring files and databases doesn’t automatically make your applications work on the new VPS. You may need to update several settings to match the new server.

Migrate a VPS: Web Server

Check the following:

  • Application configuration: Update database credentials, file paths, and environment variables.
  • File permissions: Ensure applications can access the required directories.
  • Web server: Recreate virtual hosts, rewrite rules, and website configurations.
  • SSL certificates: Install or issue certificates for your domains.
  • Firewall: Allow the required ports, including HTTP, HTTPS, and SSH.
  • Scheduled tasks: Recreate cron jobs and background processes.
  • Email: Migrate mailboxes and recreate mail settings if email is hosted on the old VPS.
  • External integrations: Update API allowlists and services that depend on the old IP address.

Remember that website migration does not automatically move email services. If your mailboxes are hosted on the old VPS, you’ll need to migrate the messages, mail accounts, and relevant settings separately.

If you use an external email provider, your mail configuration may not need to change.

Step 5: Test the New VPS

Test your applications before directing visitors to the new server. You can use its IP address, a temporary domain, or a local hosts-file entry to access the new environment.

Check that:

  1. Websites and applications load correctly.
  2. Users can log in and access the required features.
  3. Database connections work and records display correctly.
  4. Forms, uploads, and interactive features function properly.
  5. SSL certificates are valid.
  6. Cron jobs and background processes run as expected.
  7. Email sending and receiving work, if applicable.

Review application and server logs to identify errors that may not be visible on the website. Fix any problems before proceeding with the DNS switch.

Step 6: Prepare for the DNS Switch

Once testing is complete, prepare your domain for the migration.

  • Lower the DNS time to live (TTL), for example, to 300 seconds if supported by your DNS provider.
  • Make the change at least one existing TTL period before migration.
  • Schedule the switch during a period of low traffic.
  • Plan how to handle database writes and other changes during the transition.

TTL determines how long DNS resolvers may cache a record before checking for an updated value. A shorter TTL can help resolvers pick up updated DNS records sooner, but it doesn’t guarantee immediate propagation.

Step 7: Synchronize Data and Update DNS

Perform a final synchronization to capture changes made since the initial transfer.

For applications with active databases, temporarily enable maintenance mode or pause writes before exporting the final database. Alternatively, use database replication where appropriate to keep data synchronized.

Migrate a VPS: DNS Records

Once the final data is in place, update the relevant DNS records:

  • A record: Point your domain to the new IPv4 address.
  • AAAA record: Update the IPv6 address if applicable.
  • MX records: Change these only if email is also moving.

You don’t need to transfer your domain registration to the new hosting provider to move your VPS. You can keep your domain with its current registrar and update the DNS records there.

Check DNS resolution using:

dig example.com

Replace example.com with your domain name.

DNS updates may take time to be reflected across different networks because resolvers can retain cached records. During this period, some visitors may still reach the old VPS.

Monitor both servers during the transition. Check website availability, database activity, application logs, and email delivery. If the old server continues receiving traffic, make sure any new data is handled safely to avoid conflicting records between the two environments.

Step 8: Decommission the Old VPS

Don’t cancel your old VPS immediately after changing DNS. Keep it running until you’re confident that the new server is stable and all services have been moved successfully.

Confirm that:

  • Websites and applications work correctly.
  • Database records and uploaded files are complete.
  • Email and external integrations function properly.
  • No important services still depend on the old server.

Take a final backup before cancelling the old VPS. Also check your provider’s billing cycle and cancellation terms to avoid paying for a server you no longer need.

How to Minimize Downtime During VPS Migration

Some downtime may occur during a VPS migration, particularly when DNS records change or applications need to be restarted. However, proper preparation can reduce the interruption.

  1. Prepare the new VPS early: Install the required software and configure applications before moving traffic. This reduces the work left to do during the switch.
  2. Transfer large files in advance: Perform the initial transfer while the old VPS is still running. You can then perform a smaller final synchronization before changing DNS.
  3. Lower DNS TTL: Reduce DNS caching time ahead of the migration. This can help resolvers pick up the new IP address sooner, although it doesn’t guarantee immediate updates everywhere.
  4. Choose quiet hours: Schedule the switch when your website receives less traffic. This makes it easier to manage temporary interruptions.
  5. Synchronize databases: Pause writes briefly or use replication to prevent lost transactions and database inconsistencies.
  6. Keep the old VPS running: Maintain the old environment until the new server is stable and you’re confident the migration is successful.

Near-zero downtime is possible with suitable infrastructure, replication, and a carefully controlled cutover. However, a standard manual migration may still involve a short interruption.

Common VPS Migration Mistakes to Avoid

Watch out for these mistakes when moving between providers:

  • Skipping backups: Always create and verify backups before migration.
  • Forgetting databases: Transfer all application databases, not just website files.
  • Ignoring email: Migrate mailboxes and check mail settings separately.
  • Overlooking IP-dependent services: Update firewalls, API allowlists, and external integrations.
  • Changing DNS too early: Test the new server before directing visitors to it.
  • Ignoring software differences: Check operating system, PHP, database, and application compatibility.
  • Cancelling the old VPS too soon: Keep it available until the migration is confirmed successful.

Taking time to check these details can save you from troubleshooting problems after your website has already moved.

Migrate a VPS FAQs

How much does a VPS cost per month?

Is VPS hosting safe?

What are the disadvantages of VPS hosting?

Choose a Truehost Uganda VPS for Your Next Hosting Setup

Moving to another VPS provider is a good opportunity to get the resources, performance, and hosting costs your applications need.

The process is mostly about careful backups, clean transfers, and testing before switching DNS. Pay attention to database synchronization, email services, and integrations that rely on your old server’s IP address.

Take your time, keep the old server until you’re stable, and make the cutover when traffic is low.

If you’re planning a migration or setting up a new server, at Truehost, we offer VPS hosting plans with different resource configurations to accommodate your requirements.

Compare our available CPU, RAM, and storage options to find a suitable plan for your websites and applications. Choose a server that can support your next stage of growth.

Author

Leave a comment

Your email address will not be published. Required fields are marked *