XorMon migration

To migrate XorMon instance (source and target PostgreSQL and TimescaleDB have to be same version!) follow these steps:

Source instance

  1. Create backup as postgres user
    su postgres
    pg_dump -Fc -f xormon-backup.dump  -d xormon
    
  2. Shutdown the instance under xormon user
    su xormon
    cd ~/xormon-ng/
    ./xormon.sh stop
    
  3. copy and transfer configuration file(.env-backup) onto the new vm under xormon user
    cp ~/xormon-ng/server-nest/.env ~/xormon-ng/server-nest/.env-backup
    

Target instance

  1. Make sure new XorMon instance has network access to all devices on specific ports.
    Refer to this table.

  2. shutdown the instance under xormon user
    cd ~/xormon-ng/
    ./xormon.sh stop
    
  3. Prepare target database under under postgres user
    su postgres
    psql -c "drop database if exists xormon" -c "create database xormon"
    psql -d xormon -c 'CREATE EXTENSION IF NOT EXISTS "uuid-ossp";' -c "CREATE EXTENSION timescaledb;" -c "SELECT timescaledb_pre_restore()" -c "ALTER SYSTEM SET timescaledb.restoring = on;" 
    
  4. Restart database (default example)
    systemctl restart postgresql
    
  5. Restore database
    pg_restore --dbname=xormon --no-owner --role=postgres xormon-backup.dump
    
  6. Cleanup
    psql -d xormon -c "SELECT timescaledb_post_restore();" -c "ALTER SYSTEM SET timescaledb.restoring = off;"
    
  7. Restart database (default example)
    systemctl restart postgresql
    
  8. check if restoring was turned off (required for timescaledb jobs to function properly)
    psql -d xormon -c "show timescaledb.restoring;"
    
  9. Re-generate policies, get this script and run it:
    su postgres
    cd /tmp
    wget https://xormon.com/download-static/regenerate-policies.sql.gz
    
    Gunzip if needed and grant execute permissions
    If your web browser gunzips it automatically then just rename it: mv regenerate-policies.sql.gz regenerate-policies.sql
    psql -d xormon -f /tmp/regenerate-policies.sql
    
  10. move the configuration file into place under xormon user
    mv .env-backup ~/xormon-ng/server-nest/.env
    
  11. start up the instance under xormon user
    cd ~/xormon-ng/
    ./xormon.sh start