Skip to content

Draft: RocketChat MongoDB Database

Fixes

Fixes for #426 (closed) no by @Karna98

Description

Scripts to dump and restore MongoDB Database of RocketChat.

Type of PR
This PR is an improvement.

Technicalities

  1. Change the MongoDB storage engine from MMAPv1 to WiredTiger.
  2. MongoDB Database Dump and Restore script.
  3. Mongo set to ver 5.0
  4. RocketChat set to ver 4.0

Tests

  1. Disable all the other default/optional containers in config.json.dist except mongo, mongo-init-replica, rocketchat. (So that verbose logs on the terminal can be seen related to Rocketchat and mongo)
  2. Run ./dev/cdlidev.py -- --build.
  3. Visit http://localhost:2357. This is the RocketChat website.
  4. When setting up for the first time, It will ask for registration, register admin user with random details.
    Note: Make sure to add a valid email id, if you want to test it without a standalone feature. Admin email is setup in rocketchat.env. And during registration go with the standalone feature.
  5. Once done with registration, It will ask an admin for a username and you will be redirected to the newly created RocketChat.
  6. Then restore the slack dump for testing by visitng Clicking Profile Icon (top left) -> Administration -> Import -> Import New File -> Select Import Type as 'Slack' and select the slack dump file. It will upload messages first and for avtars and files click on option next to Import New File
    Create some new users, create new channels. (Minimum 2 is enough).
  7. Now send messages in various channels from different user accounts.
  8. Let's Backup now, open a new terminal and execute docker exec mongo sh -c ./dumpDatabase.sh. This will start dumping the current mongo DB in framework/dev/data/mongodb/data/dump.
  9. Once monogd ump is completed, .gz file will be created in dev/data/mongodb/data/dump.
  10. To test restore, turn down all containers, delete the cdlidev_mongo_* volume. This will delete the database.
  11. Since there is no mongo volume where MongoDB resides, when we turn up containers and visit http://localhost:2357 it shows us setup-wizard.
    To verify : Try to login with user credentials (other than admin) created before taking mongo dump.
  12. To restore previous database, execute ./restoreDatabase.sh dump-file-name.gz.
  13. On successful restoration, visit http://localhost:2357. If admin still see the setup wizard then press back or else close the browser and open again.
  14. The dump messages should be restored and reflected.

Known Issues

  1. Refer Observations of !206 (merged).
  2. When a user is on the setup-wizard page and restoration is completed, on refreshing user is still on the setup-wizard page. To view the rocketchat forum, clear the site cache and cookies and refresh it again. This is also an issue as somehow Rocketchat redirected users to setup-wizard based on the cookies and cache.

TO DO (new issues to be created)

  • Set up corn job to run dumpDatabse.sh. @NishealJ
  • Email server is the main dependency to set up all forgot password functionality and 2FA.
  • Set up auth for MongoDB and make relevant changes to connect with MongoDB for mongo-inti-replica and Rocketchat container.
  • Testing both Standalone and Rocketchat preconfigured gateways. And then decide to proceed with the Standalone feature or Rocketchat preconfigured gateways. (Registration Step 4: Register Server)
  • Testing Mobile Rocketchat Application for deployed RocketChat.

Checklist:

  • My pull request has a descriptive title (not a vague title like "Update index.md").
  • My pull request targets the phoenix/develop branch of the repository.
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no visible errors.
Edited by Vedant Wakalkar

Merge request reports