XorMon migration

XorMon can be moved from one VM to another, including configuration and performance data.
The migration involves moving the PostgreSQL/TimescaleDB database.
A prerequisite for the migration is that the same version of PostgreSQL and TimescaleDB must be installed on both the source and target systems.

The migration process includes:
  • Backing up XorMon instance
  • Installing a new VM
  • Obtaining the TimescaleDB version
  • Preparing space on the filesystem
  • Exporting the database and configuration file from the source VM
  • Importing the database and configuration file to the target VM

Backup the source XorMon instance

We strongly recommend that you back up your source XorMon instance before beginning the data migration.

Install new VM for XorMon

Choose a XorMon deployment method appropriate for your environment.

Make sure the new XorMon instance has network access to all devices on required ports.
Check local firewall configuration (ufw, firewalld).
Consult your network and security teams.

Obtain the TimescaleDB versions

  • Source instance

    Check the version of TimescaleDB running on the source instance
    # switch to root
    su -
    
    # switch to user postgres
    su - postgres
    
    # check TSDB version in database xormon
    psql -d xormon -c "SELECT installed_version FROM pg_available_extensions where name = 'timescaledb';"
    
    # example otuput
        installed_version
       -------------------
        2.19.3
        (1 row)
    Make a note of the version number. In our example, it is 2.19.3.
    We'll need it when preparing the target database.

  • Destination instance

    Check available TimescaleDB versions on the destination instance
    The version used on the source instance must be among the versions available on the target instance.
    If this is not the case, please do not proceed and contact us at support@xormon.com for further options.
    # switch to root
    su -
    
    # switch to user postgres
    su - postgres
    
    # check available TSDB versions
    psql -c "SELECT * FROM pg_available_extension_versions WHERE name = 'timescaledb';"
    
    # Abbreviated sample output
            name     | version | installed | superuser | trusted | relocatable | schema | requires |                              comment
        -------------+---------+-----------+-----------+---------+-------------+--------+----------+-------------------------------------------------------------------
         timescaledb | 2.18.0  | f         | t         | t       | f           |        |          | Enables scalable inserts and complex queries for time-series data
         timescaledb | 2.18.1  | f         | t         | t       | f           |        |          | Enables scalable inserts and complex queries for time-series data
         timescaledb | 2.18.2  | f         | t         | t       | f           |        |          | Enables scalable inserts and complex queries for time-series data
         timescaledb | 2.19.0  | f         | t         | t       | f           |        |          | Enables scalable inserts and complex queries for time-series data
         timescaledb | 2.19.1  | f         | t         | t       | f           |        |          | Enables scalable inserts and complex queries for time-series data
         timescaledb | 2.19.2  | f         | t         | t       | f           |        |          | Enables scalable inserts and complex queries for time-series data
         timescaledb | 2.19.3  | f         | t         | t       | f           |        |          | Enables scalable inserts and complex queries for time-series data
         timescaledb | 2.20.1  | f         | t         | t       | f           |        |          | Enables scalable inserts and complex queries for time-series data
         timescaledb | 2.20.3  | f         | t         | t       | f           |        |          | Enables scalable inserts and complex queries for time-series data
         timescaledb | 2.21.0  | f         | t         | t       | f           |        |          | Enables scalable inserts and complex queries for time-series data

Prepare space on the filesystem

You can check the size of the database in several ways
  • XorMon UI - Self Monitoring
    Navigate to Xormon UI -> Help -> Self Monitoring -> tab: Size

  • Psql command (as postgres)
    # switch to root
    su -
    
    # switch to user postgres
    su - postgres
    
    # check xormon database size
    psql -c "select pg_size_pretty(pg_database_size('xormon'));"
    
    # example output
        pg_size_pretty
       ----------------
        6978 MB
        (1 row)
The `pg_dump` command, which we will use to export the database, compresses the data, so the resulting backup may be significantly smaller than the database itself. Unfortunately, the compression ratio is difficult to estimate in advance, so it is best to plan for the full capacity.

Remember, you will need space for the backup file on both the source and destination instances unless you use a network shared storage.

For our example, we have set up mount points on both instances
# source instance
/mnt/xormon_export

# destination instance
/mnt/xormon_import
Configure open permissions so that different users can access the data.
# source instance
chmod 777 /mnt/xormon_export

# destination instance
chmod 777 /mnt/xormon_import

Export data from the source instance

  • Stop XorMon (as xormon)
    su - xormon
    cd ~/xormon-ng
    ./xormon.sh stop
  • Copy `.env` file (as xormon)
    su - xormon
    cp ~/xormon-ng/server-nest/.env /mnt/xormon_export/env_backup
  • Export database (as postgres)
    This step can take anywhere from tens of minutes to several hours, depending on the size of the database.
    We recommend running the command in a way where the session will not be unintentionally interrupted.
    # switch to root
    su -
    
    # switch to user postgres
    su - postgres
    
    # export dabase 'xormon'
    pg_dump --format=custom -d xormon -f /mnt/xormon_export/xormon-backup.dump
  • Copy exported data to destination instance
    scp /mnt/xormon_export/* <destination_IP>:/mnt/xormon_import

Import data on the destination instance

WARNING! This action will permanently delete the 'xormon' database on the target instance.

  • Stop XorMon (as xormon)
    su - xormon
    cd ~/xormon-ng
    ./xormon.sh stop
        
  • Prepare the target database (as postgres)
    Replace <source version> with the TimescaleDB version obtained earlier.
    # switch to root
    su -
    
    # switch to user postgres
    su - postgres
    
    # prepare the target database for import
    psql -c "drop database if exists xormon" -c "create database xormon"
    psql -d xormon -X -c 'CREATE EXTENSION IF NOT EXISTS "uuid-ossp";'
    psql -d xormon -X -c "CREATE EXTENSION timescaledb version '<source version>';"
    psql -d xormon -X -c "SELECT timescaledb_pre_restore()"
    psql -d xormon -X -c "ALTER SYSTEM SET timescaledb.restoring = on;"
  • Restart PostgeSQL (as root)
    su -
    systemctl restart postgres*
  • Import data (as postgres)
    This step can take anywhere from tens of minutes to several hours, depending on the size of the database.
    We recommend running the command in a way where the session will not be unintentionally interrupted.
    # switch to root
    su -
    
    # switch to user postgres
    su - postgres
    
    # restore data
    pg_restore --dbname=xormon --no-owner --role=postgres /mnt/xormon_import/xormon-backup.dump
  • Cleanup
    # switch to root
    su -
    
    # switch to user postgres
    su - postgres
    
    # cleanup
    psql -d xormon -c "SELECT timescaledb_post_restore();"
    psql -d xormon -c "ALTER SYSTEM SET timescaledb.restoring = off;"
  • Restart PostgeSQL (as root)
    su -
    systemctl restart postgres*
  • Copy XorMon .env file (as root)
    su -
    cp /mnt/xormon_import/env_backup /home/xormon/xormon-ng/server-nest/.env
    chown xormon:xormon /home/xormon/xormon-ng/server-nest/.env
    chmod 644 /home/xormon/xormon-ng/server-nest/.env
  • Edit DB host IP address in XorMon .env file (as xormon)
    Check and update database host IP address
    Make sure the IP address is 127.0.0.1 if the database is on the same VM as the XorMon application.
    Otherwise, set the IP address of the database server hosting the database for XorMon.
    su - xormon
    vi ~/xormon-ng/server-nest/.env
    
    # check and update database host IP address
    DB_HOST=127.0.0.1
  • Start XorMon (as xormon)
    su - xormon
    cd ~/xormon-ng
    ./xormon.sh start