Hi pranaykotas and welcome to the Mattermost community!
Make sure you read the Important Upgrade Notes, this is basically the only relevant documentation for such a big upgrade. Looking at the page, you will see that starting with 5.22.0 there are quite some big schema changes introduced to the databases and depending on your deployment model, these will take some time to finish, so prepare for a longer downtime during an upgrade.
If you use systemd for starting mattermost, you could run into a timeout while starting due to the long running migrations, so it would be a good idea to not use systemd for such big upgrades but start the server manually for the first time; this also helps with watching the logs directly being printed to the console so you can see what happens in case of errors, but if you upgrade in multiple steps, this should not be necessary.
Personally I would do the upgrade in 3 steps, although this probably isn’t necessary, but YMMV.
I’d suggest to upgrade to 5.39.3 first and if everything worked out, upgrade to 6.3.9 and then to 7.1.2.
You can find the downloadlinks for all older versions in the version archive.
Let’s assume your mattermost is installed to /opt/mattermost and you’re using MySQL for the database and your database is called “mattermost”, then you would (before running the upgrades) make sure that both the mattermost folder and the database is being backed up properly just in case you need to revert when the upgrade fails.
If my assumptions are correct, then you should run the following commands to create the backups:
tar czf mattermost-backup.tgz mattermost
mysqldump --events --triggers --routines mattermost > mattermost-backup.sql && gzip --best mattermost-backup.sql
(Depending on your mysql client configuration, you may need to add the
-u username and
-p parameter for specifying a password interactively then).
If your mattermost instance is running on a virtual machine, you could also shut it down before you start with the upgrades and take a snapshot of the virtual machine, this will help you to immediately and quickly revert to the state before the updates.
Let me know if this helps you or if you require additional information, we’re here to help