Upgrade RocketChat 7.x to 8.x

The newest release with version 8 from Rocket.Chat was released some days ago.

My self-hosted workspace is running on version 7.12.1 with MongoDB version 6.0.19. To upgrade we need to check the engine requirements from the GitHub release page. Now MongoDB version 8.2 is necessary.

To complete the upgrade just follow the official guidelines https://docs.rocket.chat/docs/guidelines-for-updating-rocketchat and https://docs.rocket.chat/v1/docs/mongodb-backup-and-restore.

For simplicity, I’ll provide here all ran commands for my instance which is running on a Debian system:

  1. Running mongodump alone from the command line without any options will assume the database is located on localhost at port 27017 with no authentication. When the backup is completed, a /dump directory is created:

    mongodump
    
  2. Upgrade MongoDB from version 6 to 7 (https://www.mongodb.com/docs/manual/release-notes/7.0-upgrade-standalone/#std-label-7.0-upgrade-standalone):

    monogsh
    
    # The 6.0 instance must have featureCompatibilityVersion set to "6.0". To check featureCompatibilityVersion:
    db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )
    
    # Shutdown mongod instance
    db.adminCommand( { shutdown: 1 } )
    
  3. Import the version 7 public key:

    curl -fsSL https://www.mongodb.org/static/pgp/server-7.0.asc | \
       gpg -o /usr/share/keyrings/mongodb-server-7.0.gpg \
       --dearmor
    
  4. Create the list file for version 7:

    echo "deb [ signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] https://repo.mongodb.org/apt/debian bookworm/mongodb-org/7.0 main" | tee /etc/apt/sources.list.d/mongodb-org-7.0.list
    
  5. Reload the package database and install MongoDB version 7.0.24:

    apt update && apt install -y \
       mongodb-org=7.0.24 \
       mongodb-org-database=7.0.24 \
       mongodb-org-server=7.0.24 \
       mongodb-mongosh \
       mongodb-org-shell=7.0.24 \
       mongodb-org-mongos=7.0.24 \
       mongodb-org-tools=7.0.24 \
       mongodb-org-database-tools-extra=7.0.24
    
  6. Check version and start MongoDB:

    mongod --version
    systemctl start mongod
    
  7. Enable backwards-incompatible 7.0 features:

    mongosh
    db.adminCommand(
       {
         setFeatureCompatibilityVersion: "7.0",
         confirm: true
       }
    )
    
  8. Upgrade MongoDB 7 to 8 (https://www.mongodb.com/docs/manual/release-notes/8.0-upgrade-standalone/#std-label-8.0-upgrade-standalone):

    monogsh
    
    # Shutdown mongod instance
    db.adminCommand( { shutdown: 1 } )
    
  9. Import the version 8 public key:

    curl -fsSL https://www.mongodb.org/static/pgp/server-8.0.asc | \
       gpg -o /usr/share/keyrings/mongodb-server-8.0.gpg \
       --dearmor
    
  10. Create the list file for version 8.0:

    echo "deb [ signed-by=/usr/share/keyrings/mongodb-server-8.0.gpg ] https://repo.mongodb.org/apt/debian bookworm/mongodb-org/8.0 main" | tee /etc/apt/sources.list.d/mongodb-org-8.0.list
    
  11. Reload the package database and install MongoDB latest 8.0.x version:

    apt update && apt install -y mongodb-org
    
  12. Check version and start MongoDB:

    mongod --version
    systemctl start mongod
    
  13. Enable backwards-incompatible 8.0 features:

    mongosh
    db.adminCommand(
       {
         setFeatureCompatibilityVersion: "8.0",
         confirm: true
       }
    )
    
  14. Upgrade MongoDB from version 8.0.x to 8.2.x (https://www.mongodb.com/docs/manual/release-notes/8.2-upgrade-standalone):

    monogsh
    
    # Shutdown mongod instance
    db.adminCommand( { shutdown: 1 } )
    
  15. Create the list file for version 8.2:

    echo "deb [ signed-by=/usr/share/keyrings/mongodb-server-8.0.gpg ] https://repo.mongodb.org/apt/debian bookworm/mongodb-org/8.2 main" | tee /etc/apt/sources.list.d/mongodb-org-8.2.list
    
  16. Reload the package database and install MongoDB latest 8.2.x version:

    apt update && apt install -y mongodb-org
    
  17. Check version and start MongoDB:

    mongod --version
    systemctl start mongod
    
  18. Enable backwards-incompatible 8.2 features:

    mongosh
    db.adminCommand(
       {
         setFeatureCompatibilityVersion: "8.2",
         confirm: true
       }
    )
    
  19. Update Rocket.Chat to 8.0.1:

    systemctl stop rocketchat
    rm -rf /opt/Rocket.Chat
    curl -L https://releases.rocket.chat/8.0.1/download -o /tmp/rocket.chat.tgz
    tar -xzf /tmp/rocket.chat.tgz -C /tmp
    cd /tmp/bundle/programs/server && npm install
    mv /tmp/bundle /opt/Rocket.Chat
    systemctl start rocketchat