Hi there, @gvolshebnik
First things first, I would recommend you to consider backing up and upgrading Mattermost to the latest supported version, which is 5.24.2 to ensure that you are up to date with the latest features, security and bug fixes.
Moving back to the process of shrinking the database, the Data Retention Policy which is available for E20 offering is the best way to go for long term solution to ensure that you only keep what you need. May I know if it would be something that you would consider?