XorMon migration
# 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.
# 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
# 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)
# source instance /mnt/xormon_export # destination instance /mnt/xormon_importConfigure open permissions so that different users can access the data.
# source instance chmod 777 /mnt/xormon_export # destination instance chmod 777 /mnt/xormon_import
su - xormon cd ~/xormon-ng ./xormon.sh stop
su - xormon cp ~/xormon-ng/server-nest/.env /mnt/xormon_export/env_backup
# 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
scp /mnt/xormon_export/* <destination_IP>:/mnt/xormon_import
su - xormon
cd ~/xormon-ng
./xormon.sh stop
# 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;"
su - systemctl restart postgres*
# 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
# 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;"
su - systemctl restart postgres*
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
su - xormon vi ~/xormon-ng/server-nest/.env # check and update database host IP address DB_HOST=127.0.0.1
su - xormon cd ~/xormon-ng ./xormon.sh start