Merge two RocketChat Servers to One

I have two rocketchat instances up and running and work without problem. this two rocketchat servers was for two separate company and the decided to merge the company’s.

thats why, we need to merge rocketchat.

my data files stores in amazon aws s3 buckets so thats easy.
but the groups, discussions, private messages are stored locally in servers.

how can i migrate one to another? i found a thread that mentioned this request before but that did not go well.

i think the first part should be to migrate both rc instances to docker, but i don’t know whats the next step :frowning:

any idea?

Server Setup Information

  • Version of Rocket.Chat Server:
  • Operating System: Ubuntu 22
  • Deployment Method: snap
  • Number of Running Instances: 2
  • Proxy: NginX
  • Firewalls involved: No

The short

Won’t hurt, but won’t help. It needs the DBs merging.

In short there isn’t one…

It would need some serious DB wrangling to merge the data.

I have seen it asked once or twice but never seen an answer.

I’ll try and ask one of the team about possibilities of merging collections.

1 Like

So a dev friend said:

In theory as long as unique users…. It might be ok

The #general channel on both would clash… not sure how well the messages and state of that channel would reconcile. Settings would clash… so would have to pick one to win and wipe out the settings in the mongodump from the other.

Other than that… it might ok-ish

You need to set up a test rig and play. I’m not sure what other duplicate issjes you’d need to check - channel names etc

Plenty if testing & backups required.

@imanerfanian please come back and share what you have to do (if you are successful in merging the servers). I am quite sure it can be useful information for another community member sometimes in the future. :pray:

here is the overall steps that i took

one of my instances version was in version 6.x.x so at first i upgrade it to version 7 ( same as another instance ) and then started the proccess.

based on my research on rc database structure, i found out i have to merge the collections below:

rocketchat_users - rocketchat_room - rocketchat_subscription & rocketchat_message

i manage to merge the collections. rocketchat service did not run bevause of Rocket.Cat duplicated is both instances. i removeed it and service started normally. it goes to “Setup wizard” page.

i set value of setup wizard from database to “Completed” and it works.

now rocketchat is up and runnin and my both users are exist, but, no message is showing to me!

even the input part is not working.

there is some errors in browser console but i really can’t figure it out anymore :frowning:

any idea?


and at last… I DID IT !
i merged this collections from source database to dest database and it works without any problem!

users
rocketchat_message
rocketchat_room
rocketchat_subscription
rocketchat_uploads
rocketchat_avatars
rocketchat_avatars.chunks

because my files stored in AWS S3 Buckets, i didn’t merge rocketchat_uploads.chunks but if you store it inside database ( not recommended ) you need to merge that too.

also, there was some duplicated usernames in both databases and before starting the merge process, i rename them and added “_old” to end of usernames.

you can skip duplicated users or even delete them. its your call.

with help of chatgpt, i wrote a python script for handling duplicated users.

just remember

  • always work on test lab
  • always create backup before doing anything. even single mongo command!
  • your both instances need to be at the same version. ( Both rocketchat & mongo )

if you need any question or need my help for this project, feel free to contact me

1 Like

Fantastic job.

Be nice if you can document how you did it a little more accurately. We may be able to add it to the documentation system.

1 Like

it would be my pleasure.

i will do it in another topic. i just don’t have a time right now but i will create full step by step with all of commands and codes as soon as possible.