This document describes how to migrate your Virtualmin installation to a new server.
The migration consists of performing a series of backups, restoring them onto your new server, testing (and more testing) -- and then, once everything appears to be working, making the new server live.
The operating system, version, and architecture don't matter during such a migration. For example, you can migrate from 32bit CentOS 6 to 64bit Ubuntu 14.04.
The following steps will guide you through performing a migration from one server to another --
Two days before moving to your new server, you'll want to decrease your DNS TTL. That will prevent your domain names from being cached, which could cause your users to be directed to your old server even after you make the switch. To lower your DNS TTL, run this command on your current server:
~# virtualmin modify-dns --all-domains --ttl 1h
That will tell DNS servers to cache your DNS entries for no more than 1 hour.
Install OS on New Server
Next, install your preferred Linux distribution onto your new server (this doesn't affect your current server in any way). The Linux distribution, version, and architecture do not need to match what you were using on your original server. However, we do suggest using a Grade A supported OS/distribution. You can see a list of those here:
Install Virtualmin onto your new server using the
virtualmin-install.sh script. If you're using Virtualmin Pro, it's okay to use your same license on both servers during your migration.
On your current server -- perform a full backup of all your Virtual Servers logging into your server as root, and running these two commands:
~# mkdir /root/backups ~# virtualmin backup-domain --dest /root/backups/ --all-domains --all-features --newformat --all-virtualmin
Copy those backups to your new server. You can do that by running this command on your current server:
~# scp -r /root/backups firstname.lastname@example.org:/root/
Restore your domains
This is the fun part! We can start restoring domains onto your new server. You can do that by running the following commands on your new server as root. Note that even on a small server, this can take some time:
~# virtualmin restore-domain --source /root/backups/virtualmin.tar.gz --all-virtualmin ~# virtualmin restore-domain --source /root/backups/ --all-domains --all-features
It will start by restoring your original Virtualmin settings, followed by restoring all of your Virtual Servers.
You'll want to test your various sites on your new server to make sure things are working properly. Since your DNS is still pointing to your live server, you may need to use the 'Preview Website' option in Virtualmin for performing your tests. If something doesn't work, there's a fair chance it's due to a missing dependency. The error messages in
$HOME/logs/error_log will give you clues as to what the problem is.
Optional: Generate New Backups
Depending on how long you performed testing, you may want to make a new backup of your Virtual Servers, and restore the new backup onto your new server, so that your data is up to date. You can generate a set of incremental backups on your existing server by running these commands:
~# mkdir /root/backups ~# virtualmin backup-domain --dest /root/backups/ --all-domains --all-features --newformat --all-virtualmin --incremental
Now for the moment of truth -- once everything is working, it's time to make your new server live. To do that, log into your domain name registrar, and update the IP address associated with your nameservers -- you'll want to set that to the IP address(es) for your new server.
Once your new server is live, do more testing! Most issues should be fairly simple to resolve. If you do happen to run into any significant issues, you can always switch the IP address for your nameservers back to the old server.
Change DNS TTL Back
Once things are working as expected, raise the DNS TTL back to the normal time. You can do that by running this command on your new server:
~# virtualmin modify-dns --all-domains --ttl 38400
Congratulations -- at this point, your migration should be complete!