If you have a Mac that has been rebuilt because it was infected with a virus or malware, and you want to restore your files using Time Machine, restore ONLY the user profiles and applications. DO NOT restore system files or library files – they can re-infect your Mac with malware, which will result in your Mac being quarantined again.
Apple Knows Their Products Best
Apple has wonderful documentation covering How to back up your Mac on their website, direct links can be found below:
Back up with Time Machine
Automatically back up all your files with Time Machine, which is built into your Mac.
Store files in iCloud
Use iCloud Drive to store and share files and learn how to access them on all your devices.
Restore your Mac from a backup
Use a backup to restore your files, even after the original files are deleted from your Mac.