Upgrade operating system from server 2012 r2 to server 2019.

We currently use Sage accounts v 28  on windows server 2012 r2. due to Microsoft retiring the OS in October 2023, we are looking to install server 2019 or 2022 and exporting the data from the old 2012 box. I would like to have guidance on how to carry this task or can a in place upgrade be done instead?