Time Machine backup strategy to avoid ransomware/other malware I am trying to develop a strategy to protect a 2016 iMac against ransomware and other types of malware. 
I have several assumptions:


An infection is going to occur when I am using it. Things such as clicking on an infected email or website.
If the computer can be compromised, then any drive that can be accessed through Finder (iCloud, Drobox, OneDrive, Google Docs or USB drive) can be compromised also.  
I can back up to a USB drive, then disconnect it. I am looking for something more automatic. (easier) Something I can't mess up or forget to do.


Could I schedule a USB drive to Mount/Unmount at a scheduled time with Automator and then set Time Machine to backup during that time?


2 am mount USB drive
2:30 am Time Machine back up.
5 am unmount USB drive
For the mounting unmounting part you can simply use the commands


  diskutil mount HDD UUID


for mounting the USB disk and


  diskutil unmount HDD UUID


You can get the UUID selecting the drive or partition in Disk Utility and clicking on "Info".

For the Time Machine part, you could use TimeMachineScheduler it let you change the interval of backups and also set time where no backups are to be done.

Let us know if that worked for you, or if not let us know more info about what version of OS X you are running etc!