A few days ago I wanted to Migrate an Ubuntu VPS from one provider to another. I tried to take a snapshot and try to migrate, but it did not work. The VPS had few random services, so migrating services one by one was not easy. What I did was set up a new Ubuntu VPS with the same OS version, rsync files from source VPS to new VPS.
Make sure you take a backup of your server before doing it. In case anything goes wrong, you should be able to restore from back or OS reload.
Install rsync on source and destination servers.
For Ubuntu/Debian
apt install rsync
For RHEL/CentOS/AlmaLinux
yum install rsync
On the source server, create a file
vi /root/no_copy
add the following content
/boot/
/etc/modules
/etc/fstab
/etc/mtab
/etc/netplan/
/etc/network/
/etc/sysconfig/network-scripts/
/lib/modules
lost+found/
/sys/
/proc/
/dev/
/var/cache/
/var/log/journal/
/swapfile
/swap.img
/usr/tmpDSK
/root/.ssh/
/backup/
/home/virtfs/
These files won’t be copied to the new VPS. If you don’t have any other folders or files, that you don’t want to be copied to the new server, you can add to the list.
Now run rsync on the source server to copy over files to the new server
rsync -avzPHAX --exclude-from=/root/no_copy / root@NEW_SERVER_IP:/
In the command above, replace NEW_SERVER_IP with the new server IP address.
When we do rsync, all files get copied to the new server. After the first rsync run, you can run the rsync command any number of times, only changed files copied, and will finish much faster as less data need to be copied to the new server.
After the first rsync is completed, we will stop all services on the source and destination servers like MySQL, Apache, Nginx, etc… so no data gets changed while we doing the rsync. Now do another rsync, reboot the destination server, see if everything works fine.
See rsync