question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Question] Restore PostgreSQL and Cassandra backups into Docker tb-cassandra

See original GitHub issue

Hi, I’ve have a question about how to restore PostgreSQL and Cassandra backups into a docker container created with the image tb-cassandra. Basically I had a previous installation of Thingsboard + PostgreSQL + Cassandra into file system. Now I have a docker container which works good, I need to import all backups (.sql file from postgre and the .tar from cassandra), has anyone some advice to do that?

Thanks!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

3reactions
jonrot1906commented, Sep 12, 2021

Haven’t tried it, but theoretically it should work to:

  1. Create a new folder ${NEW_FOLDER}
  2. Copy /var/lib/postgresql/11/data or /var/lib/postgresql/12/data (your local postgresql installation) to ${NEW_FOLDER}/db
  3. Copy cassandra folder of your local Cassandra installation to ${NEW_FOLDER}/cassandra (check if it contains subfolders like data, commitlog…)
  4. Create .firstlaunch and .upgradeversion files, last one containing the version of your current Thingsboard Docker installation (i.e. 3.3.1) inside of ${NEW_FOLDER}
  5. Set 777 permissions to ${NEW_FOLDER} (see here)
  6. Set up docker-compose.yml file, defining ${NEW_FOLDER}:/data under volumes
  7. Enjoy

That should work, but I haven’t tried (maybe doing it tomorrow). Backup your data before trying. As you see, I wouldn’t do it by using your backup files as Thingsboard uses the whole database installation folders.

0reactions
Ultrazombiecommented, Jun 15, 2022

@fgnm Hello, We are using the docker exec command for PostgreSQL, and sstableloader for Cassandra e.g. restore for PostgreSQL: docker exec -i container_name psql --username postgres -d db_name </path/on/your/machine/dump.sql and for Cassandra: sudo sstableloader --verbose --nodes 127.0.0.1 ./thingsboard/ts_kv_latest_cf

Also, you can explore our scripts by the path: https://github.com/thingsboard/ThingsboardSupport/tree/main/databases

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cassandra backup and recovery | Apigee X - Google Cloud
Restoration takes your data from the backup location and restores the data into a new Cassandra cluster with the same number of nodes....
Read more >
How to backup the cassandra running in docker container
just mount cassandra docker volume in host somewhere and take backup as usual with Snapshotter . you can mount docker Cassandra directory /var/ ......
Read more >
Running Cassandra and PostgreSQL in Docker
In this post I describe how to set up the environment using Docker containers for Cassandra and Postgres so that you don't have...
Read more >
Newest 'restore' Questions
I'm trying to restore a database backup that is on a server. This server is on a remote machine and runs in a...
Read more >
Backing up your Postgres Database | by Gary Sieling - Medium
For a running system, you must use a backup method that handles database transactions. Postgres supports two options — you can choose to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found