Script to migrate Rocket.Chat databases to Matrix Synapse
Go to file
2023-06-22 17:18:10 +02:00
.husky Add lint-staged 2023-05-23 13:40:40 +02:00
.vscode Add cSpell workspace-specific dictionary 2023-06-05 13:57:38 +02:00
src Move user exclusion test to user handler 2023-06-22 17:18:10 +02:00
.editorconfig Set up TS, linter and formatter 2023-05-19 17:16:13 +02:00
.env.example Move user exclusion test to user handler 2023-06-22 17:18:10 +02: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 Set up TS, linter and formatter 2023-05-19 17:16:13 +02:00
.woodpecker.yml Update CI config to run tests with --ci option 2023-06-19 20:39:14 +02:00
docker-compose.yml Implement user registration functions 2023-05-25 16:31:06 +02:00
draft.drawio INIT 2023-05-17 18:45:48 +02:00
jest.config.js Add user mapping test 2023-05-26 17:42:03 +02:00
package-lock.json Restructure rooms codebase and write tests 2023-06-16 19:58:14 +02:00
package.json Restructure rooms codebase and write tests 2023-06-16 19:58:14 +02:00
README.md Add cleanup script to reset dev environment 2023-06-14 13:37:57 +02:00
reset.sh Add cleanup script to reset dev environment 2023-06-14 13:37:57 +02:00
tsconfig.json Add sqlite database for ID mappings 2023-05-26 14:56:16 +02:00

Rocket.Chat to Matrix Migration Script

Drafts and more. This is a work in progress!

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/

Running the Matrix Dev Server

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, you SHOULD 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

Continue setting up the server:

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 -c /data/homeserver.yaml --admin --user verdiadmin --password verdiadmin

Then you can access the homeserver in Element Web or the local admin interface as http://localhost:8008 with the verdiadmin as username AND 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": "verdiadmin","password": "verdiadmin","device_id": "DEV"}' \
> src/config/synapse_access_token.json

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

Configuration

Copy over .env.example to .env and insert your values.

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, excluding the generate command.

Design Decisions

  • Getting data from Rocket.Chat via (currently) manual mongodb export
  • Room to Channel conversion:
    • Read-only attributes of 2 verdigado channels not converted to power levels due to complexity