Migration
Server migration
This is a guide on how to migrate the Master or Slave server (standalone only) from the old machine to the new one.
Preparation
Make sure that:
- Both servers use CPUs with the same architecture (for example x86_64)
- Major OS versions on both servers must match
- The new server should have enough free space to receive all the original server's files
- The new server has the same hostname and PTR (rDNS) as the old one
Steps
First, stop CrossBox on the old server:
crossbox stop
Next, SSH onto the new server and start the rsync command:
rsync --archive --recursive --update --links --hard-links --perms --acls --xattrs --owner --group --times --devices --progress --executability --exclude='/etc/fstab/*' --exclude='/etc/network/*' --exclude='/proc/*' --exclude='/tmp' --exclude='/sys/*' --exclude='/dev/*' --exclude='/mnt/*' --exclude='/boot/*' --exclude='/root/*' root@SOURCE_SERVER_IP:/ /
Replace the SOURCE_SERVER_IP in the command above with your old server IP. Make sure that the final command has no newlines.
After the rsync finishes the transfer, SSH as root into your old server, and create a new directory:
mkdir ~/migration
Place migrate.sh script:
cd ~/migration
nano migrate.sh
with the following content:
ID_minimum=500
for f in /etc/{passwd,group}; do awk -F: -vID=$ID_minimum '$3>=ID && $1!="nfsnobody"' $f |sort -nt: -k3 > ${f#/etc/}.bak; done
while read line; do grep -w "^${line%%:*}" /etc/shadow; done <passwd.bak >shadow.bak
while read line; do grep -w "^${line%%:*}" /etc/gshadow; done <group.bak >gshadow.bak
Run migrate.sh:
sh migrate.sh
You should now see 4 new files present in the current directory (passwd.bak, group.bak, shadow.bak, and gshadow.bak).
Inspect them to ensure the appropriate users and groups were gathered.
Next, transfer each of the 4 files onto the new system, using rsync, SCP, or some other method.
After the transfer, run the following command on the new server:
for f in {passwd,group,shadow,gshadow}.bak; do cat $f >>/etc/${f%.bak}; done
Let CrossBox on your new server know about this server's IP Address by editing /home/crossbox/app/installer.json and updating the public_ip_address:
{
...
"public_ip_address": "NEW.SERVER.IP.HERE",
...
}
Next, log in to your crossbox.io account, go to licenses and Reissue the license for the old server.
Run the following commands on the new system:
crossbox reload-config
crossbox sync-all
crossbox reload-firewall
crossbox restart
Check the CrossBox status command to verify all services are up:
crossbox status
Finally, change an A record in your domain's DNS settings to point to the new server's IP address.