Time Machine backup strategy to avoid ransomware/other malware
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!