How to Migrate Beezkeeper data to a new server

Introduction
In this tutorial we will be covering how to migrate your NetBeez configuration & data from 1 server to another. We will be including links on how to configure the new server to get started with. Please note, this method should ONLY BE USED if you cannot export the existing image or snapshot and import it into a new machine. That method is significantly easier to accomplish and we would be happy to assist if needed.

Step 1: Preparations:

  1. Follow this guide here to set up up the new server (Destination).
  2. Refer to the firewall rules here for the new server (Destination)
  3. The Destination server should be reachable by the source server via port 22. i.e. Source → port 22 → Destination
  4. Check the storage on the new server with lsblk and if you need help expanding the partition (default is 100GB), see below:
    SSH to the server
    Execute the following commands (partition names may be different, verify when you run lsblk
growpart /dev/sda 3
pvresize /dev/sda3
lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
  1. Recheck with lsblk

Step 2: Source Server

  1. SSH to the server
  2. Execute the commands one at a time
    x.x.x.x is the IP of the destination server:
nb-docker-compose stop nb-msgsrv nb-commsrv nb-dashboard nb-api nb-jobs
cd /tmp

sudo tar -zcvf nbdb.tar.gz /var/lib/mysql
sudo tar -zcvf nbinflux.tar.gz /var/lib/influxdb2
sudo tar -zcvf user_data.tar.gz /opt/netbeez/user_data
sudo chown netbeez nbdb.tar.gz nbinflux.tar.gz user_data.tar.gz

ssh-keygen -R "x.x.x.x"
scp nbdb.tar.gz nbinflux.tar.gz user_data.tar.gz netbeez@x.x.x.x:/tmp/
md5sum nbdb.tar.gz nbinflux.tar.gz user_data.tar.gz

Step 3: Destination Server

  1. SSH to the server
nb-docker-compose down
cd /tmp/
md5sum nbdb.tar.gz nbinflux.tar.gz user_data.tar.gz # Make sure the md5s match

tar xzvf nbdb.tar.gz
tar xzvf nbinflux.tar.gz
tar xzvf user_data.tar.gz

mv /var/lib/mysql /var/lib/mysql_orig
mv /var/lib/influxdb2 /var/lib/influxdb2_orig
mv /opt/netbeez/user_data /opt/netbeez/user_data_orig

mv /tmp/var/lib/mysql /var/lib/mysql
mv /tmp/var/lib/influxdb2 /var/lib/influxdb2
mv /tmp/opt/netbeez/user_data /opt/netbeez/user_data

nb-docker-compose up -d
  1. Check to make sure the containers are healthy with ‘docker ps’
  2. Reboot
  3. Check FQDN/IP on your web browser

Step 4: Update IP (Optional)
If you are moving the destination server after this is completed, you may need to update your IP

  1. SSH to your server
  2. Log in as Root
  3. Execute the following commands
    ls /etc/netplan/ to find your config files
    Nano or Vim /etc/netplan/<your-config-file>.yaml
    Update IP, Gateway, Nameservers, etc
    sudo netplan apply
  4. Reboot the server
  5. Update DNS record (if needed)
  6. Verify the server is reachable

Additional Notes
Depending on your setup, there may be additional steps required such as additional permissions or processes to move the files between 2 different networks. If you get stuck please email support@netbeez.net

This process may take awhile, depending on how large the database is, how much bandwidth is available on the network and how powerful the source and destination are. It took about 15 minutes to move around 130GB between files from my testing but your experience may vary. Please allow ample time for each process to complete

Conclusion
This is a relatively easy to follow guide but can vary from environment to environment. But this is the best way to do a migration IF you cannot export the existing image and import it into another virtual instance.

1 Like

This guide is valid as of version 14.x of the Beezkeeper.