I use for online, backblaze but there are others. You have to look for one that will save it over time. Some online will only do 30 days. One other question? Was your computer backing up to your icloud account. you might want to log into
https://www.icloud.com/ using your log on for your computer and your password and see if it backed up any data to your icloud .
I had to replace my G-Technology 6TB external thunderbolt drive . I had noticed my computer was having the spinning beachball alot and all that, but when it was rebooting, I knew something was wrong and figured it out when I could no longer see that drive. I played musical ports, cables, even used the USB cable , swapped cables and came to the conclusion it was dead. Of course I had backups with Backblaze and had my WeatherCat data in my documents folder so it was backed up.
Now I have a LaCie 4TB solid state backup and it is fine. I might replace my 4TB down the road as it has my weather stats and stuff on it and it is beginning to chatter . With weather data, back up is key . You might see if anyone can recover the data from your imac drive.
I wish you the best, but having a good online backup for imac and a local is paramount.