Ah, OK... 2012 is a nice one. Still sold by Apple as new until late 2016, IIRC. It's the last Mac sold with an internal DVD drive. Easy to upgrade to 16GB ram. And, you can replace the DVD with an SATA hard drive, so have two internal drives. It's a choice, eh?
Mountain Lion would be the system that 2012 originally shipped with.
If you still have a HDD, and not a SSD, I would suggest that El Capitan, or the older Yosemite would work better.
But, with an SSD as a best choice, the 2012 can upgrade to Catalina (10.15.7), although
I have the opinion that Mojave is a better "fit" for that one. Lets you continue to use 32-bit apps, for example. The USB-3 ports make the use of external storage noticeably faster.(compared to 2011 Macs, which were still stuck with USB 2.
Sorry if my "system refresh" plan was a little confusing. You would not need to erase the original boot drive if you were swapping in the drive that you have backed up. You install that backed up drive, replacing the original boot drive. and THAT one then becomes your back up.
Yes, it would be my plan that the back up is NOT a pefect copy. I would expect that at least parts of the system software would be replaced with non-corrupted files -- and system caches would be cleaned up as part of the reinstall process. So, no, not an identical copy, but (I'm hoping) an improved copy.
An example of this: I did this install/migrate twice for a customer, who came in loaded with all kinds of "shopping malware/adware". The browser (Safari, I think) hardly worked, as EVERY link went through the same few sites, all re-directs. Left the system extremely slow, and the customer hardly had any software that was NOT affected in some way. I couldn't do anything without having nearly a full minute of the "spinning wheel". Click again, and more spinning wheel.
Just a single scan with Malwarebytes found more than 60 instances of "possible questionable programs" and multiple examples of known malware. Cleaning all that off, through Malwarebytes, made a big difference, but still not quite working smoothly.
I did that "backup, erase, reinstall, restore", and the improvement was amazing, and, in the end, "just a refresh" -- but it worked really well.
I think your plan should work OK. Let me know how it goes.
(You CAN buy macOS installers, preloaded on USB flash drives - I can't tell you anything about the sources, just that they are available. But,
this seller does include a free "silver" necklace with every purchase! I'm pretty sure that makes it good Mac software

)