Before you completely give up on attempting to restore a backup, confirm your iMac does not have a Time Machine backup of a Mojave installation you can use. The reason for asking is that it is possible to restore backups of other Macs. Scroll through its list of available backups to determine if it shows one for macOS 10.14.
Without a backup? Start by following the instructions for What to do before you sell, give away, or trade in your Mac.
In Step 7, in the instructions to erase your hard drive and reinstall macOS you will completely erase the disk according to How to erase a disk for Mac. You will be following the first set of instructions—those under How to erase your disk. In its Step 7, where it discusses how to reinstall macOS on the disk you just erased, you will be restarting the Mac using the key chord to Reinstall the macOS that came with your Mac, or the closest version still available.
If that installed macOS version is not Mojave, upgrade it according to How to upgrade to macOS Mojave.