At this point there are not any known Mac viruses in the wild, so you may have been infected with some sort of malware or adware. But yes, if you have malware on your Mac, then backup that Mac to another drive, the malware will go along with the backup.
Can you explain what happened to make you think you are infected an maybe we can help you sort it out.