Skip to content

Instantly share code, notes, and snippets.

@WillNilges
Last active December 6, 2021 21:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WillNilges/d2561e1ceaf79cdf64b3f1d3442e840f to your computer and use it in GitHub Desktop.
Save WillNilges/d2561e1ceaf79cdf64b3f1d3442e840f to your computer and use it in GitHub Desktop.
A couple of unorganized notes on how to migrate thingsboard DBs

Backing up

Postgres

Source: https://thingsboard.io/docs/user-guide/install/pe/upgrade-instructions/#prepare-for-upgrading-thingsboard-centos-ubuntu

To move the Postgres DB, get a shell into the PostgreSQL container running on your instance. Use psql to make a backup of the DB. This can be done while the postgres server is running.

docker ps | grep postgres # Use this to find the container ID
docker exec -it 058d8f344e05 pg_dump -U postgres thingsboard > /var/lib/postgresql/data/thingsboard.sql.bak

Then, put that somewhere safe.

scp /mnt/data/thingsboard-pe/tb-node/postgres/thingsboard.sql.bak wilnil@somewheresafe.example.com:~/

Cassandra

Stop the instance, and just copy the entire dir somewhere safe.

docker-compose down
scp /mnt/data/thingsboard-pe/tb-node/cassandra wilnil@somewheresafe.example.com:~/

Restoring

Postgres

Use psql to restore the dump.

Cassandra

Copy the whole cassandra directory to the new instance

scp -r ~/cassandra thingsboard@newinstance.example.com:/var/lib/cassandra
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment