> Shall I just make a backup of the folder $HOME/Library/Mail
Yes, that has worked (another approach might be to export/import from Mail but I have not used that).
When doing a clean install I have just zipped ~/Library/Mail and then expanded and imported that to a new macOS Mail.app (I have then moved local mail to an upper level and deleted imported gmail which is online anyway).
A few years ago it was enough to just put the Mail folder back at ~/Library but that does not work anymore. AFAIR in El Capitan to Mojave I ended up using Emailchemy to convert the mail because then none of the workflows mentioned above worked 100% -- I either got missed or duplicated messages).