I'm guessing you have a Fusion Drive and are planning to replace the drive, but I could be wrong. Either way, if the system is bootable, you could boot up and back up the system to an external drive via Time Machine. Otherwise, if the system isn't bootable, then to clone everything you would need another computer or a bootable external drive. If using another computer, you would put the iMac in target disk mode and connect it to the other computer, then on the other computer you would use a program like Carbon Copy Cloner to cloner the drive in the iMac to an external drive. If you're using a bootable external drive, you would connect that to the iMac, boot into it, then use Carbon Copy Cloner to clone the internal drive to an external drive. Good luck!