Script to migrate Rocket.Chat databases to Matrix Synapse. Mirrored to https://github.com/verdigado/rocketchat2matrix
Go to file
Henrik HerHde Huettemann b60454e81e
ci/woodpecker/pull_request_closed/woodpecker Pipeline was successful Details
ci/woodpecker/push/woodpecker Pipeline was successful Details
Update Woodpecker config
2024-01-26 16:24:57 +01:00
.husky Adapt changes for Husky v9 2024-01-26 15:59:14 +01:00
.vscode Add cSpell workspace-specific dictionary 2023-06-05 13:57:38 +02:00
src Fix linter issue 2024-01-26 15:00:58 +01:00
.editorconfig Set up TS, linter and formatter 2023-05-19 17:16:13 +02:00
.env.example Add syanpse URL and admin password variables 2023-11-23 16:56:37 +01:00
.eslintrc.yaml Set up TS, linter and formatter 2023-05-19 17:16:13 +02:00
.gitignore Add sqlite database for ID mappings 2023-05-26 14:56:16 +02:00
.markdown-style.rb Add CI, mdl and pre-commit 2023-05-20 10:41:41 +02:00
.mdlrc Add CI, mdl and pre-commit 2023-05-20 10:41:41 +02:00
.pre-commit-config.yaml Run pre-commit via husky hook 2023-05-22 16:12:41 +02:00
.prettierrc.yaml Add previous prettier trailing comma default 2023-09-01 16:23:19 +02:00
.woodpecker.yaml Update Woodpecker config 2024-01-26 16:24:57 +01:00
LICENSE Add LICENSE 2023-11-15 10:46:55 +01:00
README.md Update new user command to be more explicit 2024-01-26 13:23:53 +01:00
app-service.example.yaml Add Application Service and documentation 2023-09-01 11:58:54 +02:00
docker-compose.yaml Renovate: Update all non-major dependencies 2024-01-26 14:03:56 +00:00
jest.config.js Add user mapping test 2023-05-26 17:42:03 +02:00
package-lock.json Renovate: Update dependency husky to v9 2024-01-26 14:34:16 +00:00
package.json Adapt changes for Husky v9 2024-01-26 15:59:14 +01:00
renovate.json Add renovate.json 2023-09-01 11:09:11 +00:00
reset.sh Add syanpse URL and admin password variables 2023-11-23 16:56:37 +01:00
tsconfig.json Add sqlite database for ID mappings 2023-05-26 14:56:16 +02:00

README.md

Rocket.Chat to Matrix Migration Script

Script to migrate users, channels and messages from Rocket.Chat communication platform to a Matrix Synapse server. It currently has beta quality and comes with no warranty.

Installation and Usage

This setup is intended to migrate from Rocket.Chat to Synapse once, using mongo database dumps and a fresh Synapse instance. After the migration and some clean up, the Synapse might be used by users.

Exporting RC data

Currently manually via mongodb. Run the following on the server:

mongoexport --collection=rocketchat_message --db=rocketchat --out=rocketchat_message.json
mongoexport --collection=rocketchat_room --db=rocketchat --out=rocketchat_room.json
mongoexport --collection=users --db=rocketchat --out=users.json

Export them to inputs/

Configuring the Matrix Dev Server

Generate a Synapse homeserver config with the following command (you might change my.matrix.host for the actual server name, as it can't be changed afterwards):

docker-compose run --rm -e SYNAPSE_SERVER_NAME=my.matrix.host -e SYNAPSE_REPORT_STATS=no synapse generate

To run the script without hitting rate limiting and activating an Application Service to send messages by different users with our desired timestamps, you MUST add the following options to the freshly generated files/homeserver.yaml. Do not leave these in the production setup!

rc_joins:
  local:
    per_second: 1024
    burst_count: 2048
rc_joins_per_room:
  per_second: 1024
  burst_count: 2048
rc_message:
  per_second: 1024
  burst_count: 2048
rc_invites:
  per_room:
    per_second: 1024
    burst_count: 2048
  per_user:
    per_second: 1024
    burst_count: 2048
  per_issuer:
    per_second: 1024
    burst_count: 2048
app_service_config_files:
  - /data/app-service.yaml

Now edit app-service.example.yaml and save it at files/app-service.yaml, changing the tokens manually.

Copy over .env.example to .env and insert your values. Also export the variables with source .env.

Starting the Matrix Dev Server

Boot up the container and (for the first time starting the server or after resetting it manually) create an admin user:

docker-compose up -d
# Wait for the Server to boot, then register an admin user
docker-compose exec -it synapse register_new_matrix_user http://localhost:8008 --config /data/homeserver.yaml --admin --user $ADMIN_USERNAME --password $ADMIN_PASSWORD

Then you can access the homeserver in Element Web or the local admin interface as http://localhost:8008 with your $ADMIN_USERNAME/$ADMIN_PASSWORD as username/password.

Store an access token for that user:

curl --request POST \
  --url http://localhost:8008/_matrix/client/v3/login \
  --header 'Content-Type: application/json' \
  --data "{\"type\": \"m.login.password\",\"user\": \"$ADMIN_USERNAME\",\"password\": \"$ADMIN_PASSWORD\",\"device_id\": \"DEV\"}" \
> src/config/synapse_access_token.json

Installing and Running the Script

Install NodeJS >= v19 and npm on your system, install the script's dependencies via npm install.

To finally run the script, execute it via npm start.

Running Tests

npm test.

Cleaning Up

To clean up the Synapse server and local storage database, run either the convenience script ./reset.sh or start with:

docker-compose down
sudo rm files/homeserver.db
rm db.sqlite

Then you can restart with an empty but quite equal server, following the instructions above to start the dev server.

Design Decisions

  • Getting data from Rocket.Chat via manual mongodb export
  • Room to Channel conversion:
    • Read-only attributes of channels not converted to power levels due to complexity
  • Reactions:
    • So far only reactions used in our chats have been translated
    • Individual logos of netzbegruenung and verdigado have been replaced by a generic sunflower
    • Skin colour tones and genders have been ignored in the manual translation, using the neutral versions
  • Discussions are not translated, yet, as they have a channel-like data structure which probably should be translated to threads
  • Several state change events are not translated, as the previous state is unknown, but the final state should be equal
  • If the root message of a thread is deleted or of a deleted user, the thread will be skipped
  • The script follows a design to easily continue a migration if the script crashed by restarting it

Contributing

This FOSS project is open for contributions. Just open an issue or a pull request.

License

Licensed under AGPL v3 or newer. Copyright 2023 verdigado eG support@verdigado.com.

Support

Contact support@verdigado.com to get an offer for personal or commercial support. Community support might be provided through the issue tracker.