How To Change Vps Providers, How To Migrate Linux Vps, How To Migrate Server Using Rsync, How To Migrate Vps, How To Migrate Vps From Old Server To New Server, How To Migrate Vps From Old To New, How To Move Vps Providers, How To Switch Vps, Linux Server Migration, Linux Vps Migration, Low End Virtual, Migrate Linux Vps, Migrate Server Rsync, Migrate Vps, Migrate Vps Providers, Move Linux Server, Rsync Command To Migrate Server, Rsync Migration Method, Rsync Transfer Linux, Transfer Data Rsync, Transfer Vps Using Rsync, Vps Migration Method

A Step-by-Step Guide to Migrating Your Linux Server with Rsync: Seamless Transfer for VPS and Dedicated Servers

Article contributed by Dustin B. Cisneros from RackNerd. If you are looking for a VPS hosting solution, consider checking out RackNerd. RackNerd is a well-established brand with a solid reputation and has been featured in Inc. multiple times! They are also quite popular around here. Be sure to check their latest offers here.

Are you thinking about changing VPS providers or upgrading your VPS to a new server? This guide will provide you with step-by-step instructions on transferring your Linux server from an old VPS to a new one. Whether you are adopting a hands-on approach to your migration, shifting to a different provider, or simply refreshing your server environment, this guide will assist you in migrating your data and configurations seamlessly.

When it comes to migrating your VPS, there are a variety of methods available, ranging from the straightforward to the highly intricate. The best migration strategy for you will largely depend on your specific setup, level of technical know-how, and the type of content you have hosted. This guide outlines one of the simpler techniques for performing a VPS migration, but keep in mind that it’s just one of the many options at your disposal.

Other Migration Methods

The method we are about to discuss allows you to replicate almost everything 1:1 (with the exception of system-specific configuration files) from one server to another by utilizing a tool known as rsync. This approach is an effective migration strategy for a vast majority of use cases. However, it’s crucial to understand that when migrating from one VPS to another, there isn’t a universal solution. The most suitable migration technique can differ significantly based on your particular requirements, software environment, hosted content, and level of technical expertise. Here are some essential considerations:

  1. Tailored Approaches: Sometimes not all elements need to be migrated. A more focused strategy that emphasizes specific components may actually prove to be more effective.
  2. Built-in Tools: Various hosting control panels, such as cPanel, DirectAdmin, and Plesk, provide built-in migration tools intended for effortless transitions within their frameworks.
  3. Specialized Solutions: Depending on your configuration, you might find value in specialized migration tools or services that cater to particular applications or environments.
  4. Partial Migrations: In certain scenarios, you may choose a partial migration, which involves transferring only crucial files or data while rebuilding the remaining environment from scratch on the new server.
  5. Environment-Specific Methods: The characteristics of your environment—whether it involves a LAMP stack, a Node.js application, or a complex microservices architecture—can greatly influence the ideal migration strategy.

Remember that every environment is distinctive. What might be suitable for one setup could be less effective for another. Only you or the person responsible for your server’s configuration can appreciate the nuances of your environment and decide on the most fitting migration method.

As you prepare for your migration, take into account the specific components that require transfer, along with any interdependencies among different system parts. Ultimately, the optimal migration strategy is one that meets your unique needs, reduces risks, and ensures uninterrupted service continuity. If you find yourself uncertain about the best course of action for your situation, don’t hesitate to consult with an experienced Linux system administrator or your trusted IT professional.

Prerequisites

Before we get started, make sure you have the following items prepared:

  1. Your source VPS (the server you intend to migrate from)
  2. Your destination VPS (the server you are migrating to). Ensure that the destination VPS has a clean installation of the same operating system version as your source VPS (it should not have any software installed or running — it needs to be a fresh instance).
  3. Both servers should be accessible via SSH
  4. Important: Confirm that rsync is installed on both servers. If it’s not present, you can install it with the following commands:

For CentOS, AlmaLinux, or Rocky Linux:

To install rsync on a CentOS or RHEL system, you can use the following command:

sudo yum install rsync -y

For Ubuntu or Debian users, the command is slightly different:

sudo apt-get update && sudo apt-get install rsync -y

  1. Critically important! Make sure that the new VPS runs the same version of the operating system as the old one. Discrepancies can lead to complications. Verify this carefully. You can execute the command cat /etc/os-release on both servers to confirm that they match perfectly.

Creating the Exclusion List

Before commencing the migration, we will establish an exclusion list. This list is essential for streamlining the migration process by pinpointing directories and files that are not required to be moved to the new VPS.

It is important to determine which directories to exclude based on your unique setup. The exclusions are advantageous for several reasons:

  1. Minimizing transfer time and bandwidth consumption by avoiding the transfer of unnecessary files.
  2. Preventing the transfer of system-specific files that may lead to conflicts on the new server.
  3. Ensuring that critical system files on the destination VPS are not accidentally overwritten.

The specific list may differ from one system to another, based on your unique setup and requirements. Nevertheless, we have assembled a compilation of frequently excluded directories and files that should be applicable in most scenarios. You are welcome to adjust this list according to your individual needs.

Here’s a guide on how to set up and fill in the exclusion list:

  1. On your source server, initiate a plain text file by entering:

sudo nano /root/excludedfiles.txt

  1. Once the file is open, copy and paste the following list. This serves as a starting point, covering many standard exclusions:

/etc/fstab

/etc/sysconfig/network-scripts/*

/etc/systemd/network/*

/etc/network/*

/etc/netplan/*

/etc/NetworkManager/*

/etc/resolv.conf

/etc/hostname

/etc/hosts

/etc/machine-id

/var/lib/dbus/machine-id

/proc/*

/tmp/*

/sys/*

/dev/*

/mnt/*

/boot/*

/boot/grub/*

/etc/default/*

/run/*

/var/run/*

/var/lock/*

/media/*

/lost+found

/swapfile

/swap.img

/var/lib/rpm/*

/var/lib/yum/*

/etc/sysconfig/iptables

/etc/iptables/rules.v4

/etc/iptables.rules

/var/lib/iptables/rules-save

/etc/ssh/*

/var/crash/*

/var/log/*

/var/cache/apt/*

/var/lib/apt/lists/*

/var/lib/cloud/*

/sys/class/dmi/id/product_uuid

/etc/udev/*

/lib/modules/*

/lib/firmware/*

/lib64/modules/*

/lib64/firmware/*

  1. Save the file by hitting the CTL + X keys on your keyboard, followed by y, and enter. You will then be directed back to the SSH prompt for your source VPS.

This list excludes system-specific directories, temporary files and caches, log files, and other data that either shouldn’t be transferred and/or has already been generated on the new system. It also excludes some configuration files that are typically unique to each server and might cause conflicts if transferred.

Keep in mind that while this list serves as a helpful starting point for various environments, you may need to modify it according to your specific setup. If you have any doubts about particular exclusions, it’s advisable to reach out to a Linux systems administrator who is knowledgeable about your configuration.

Executing the Migration

Now we are ready to carry out the migration. As a reminder, ensure that rsync is installed on both servers, as mentioned in the “Prerequisites” section of this article.

  1. First, take the command provided below and save it in a notepad on your local machine so that we can tailor it to your specific needs.

sudo rsync -vPa -e 'ssh -p 22 -o StrictHostKeyChecking=no' --exclude-from=/root/excludedfiles.txt / root@REMOTE-IP-OF-THE-NEW-SERVER:/

Within your text document, substitute `REMOTE-IP-OF-THE-NEW-SERVER` with the IP address of your new VPS. If necessary, update ’22’ to reflect your custom SSH port if you have one configured.

  1. After making your changes, select the entire command in your text document and copy it by pressing CTL + C. Then, paste it into your SSH terminal (remember to ensure you are logged into the source VPS at this time).

You will need to provide the password for the new VPS to establish communication between your old and new servers. Enter the password and hit enter.

  1. This process may take some time depending on the amount of data being transferred. Once it’s complete, you’ll notice something similar to the below screenshot, and you’ll also see that your SSH session returns to a ready prompt:
  1. At this point, power down your old source server, and reboot your destination server. Typically, these functions should be accessible in your provider’s VPS control panel area. For instance, if you’re using RackNerd, you can perform these actions through the SolusVM control panel (also known as “NerdVM”).
  2. After rebooting the destination server and allowing a few minutes for it to come back online, connect to your new server (the destination server) via SSH. Important: Use the IP address of your new server for connection, but enter the root password from your old server to log in. This is because the migration process transferred the user and password configurations from the old server to the new one. Ensure you don’t confuse the passwords – you’re logging into the new server with the credentials from the old server.
  3. To verify the transfer, log into your destination VPS and check that your files are present.

Post-Migration Steps

After the migration is complete:

  1. Update your DNS records to redirect to your new VPS IP address if necessary.
  2. Check and modify any configuration files that may still reference your previous VPS IP address.
  3. Restart any services that were operational on your previous VPS on the new one.
  4. Verify your websites and applications to confirm they are working properly on the new VPS.

Important Considerations

While this technique offers a straightforward method for migrating your VPS, it’s crucial to recognize its limitations. This approach is not entirely automated, and its success is heavily reliant on your software stack and environment.

For instance, if you are utilizing a hosting control panel like cPanel, this method might not be the best choice due to the many dependencies involved, which could lead to potential problems. In such scenarios, it’s recommended to adhere to the migration procedures suggested by your software stack. For example, cPanel/WHM offers a dedicated transfer tool feature specifically designed for migrations.

Additionally, some configurations that point to your previous VPS IP address may carry over during this process (such as web server software settings). You might need to modify these to reflect your new VPS IP after the migration.

The success of this migration technique can differ significantly based on your unique configuration. If you’re uncertain about the best way forward, it’s strongly advised to seek guidance from a knowledgeable Linux systems administrator and/or your IT team prior to initiating any migration.

Conclusion

This guide offers a straightforward technique for executing a nearly 1:1 migration of your Linux server from one machine to another using the rsync tool. The strategy discussed here is just one among many potential migration methods you could explore.

If you are contemplating a transition in your VPS environment or seeking to enhance your current VPS, this migration journey presents a fantastic opportunity! For anyone searching for a new VPS provider, check out RackNerd’s latest Linux VPS promotions by clicking here. RackNerd’s competitive prices make it a perfect choice for you, all at a significantly lower cost than other alternative cloud providers.

Leave a Reply

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