To keep your files safe, it’s important to back up your iMac regularly. The easiest way to back up is to use Time Machine—which is built into your Mac—to back up your apps, accounts, preferences, music, photos, movies, and documents (it doesn’t back up the macOS operating system). Use Time Machine to back up to an external storage device connected to your iMac, or to a supported network volume. For a list of devices supported by Time Machine, see the Apple Support article System Preferences, click Apple ID, then click iCloud and deselect Optimize Mac Storage. The contents of your iCloud Drive will be stored on your Mac and included in your backup.
iCloud Photos: Open Photos, then choose Photos > Preferences. In the iCloud pane, select “Download Originals to this Mac.” Full-resolution versions of your entire photo library will be stored on your Mac and included in your backup.
Restore your files. You can use Time Machine to restore all your files at once. Click the Time Machine icon in the menu bar, then choose Enter Time Machine. (If the Time Machine icon isn’t in the menu bar, choose Apple Menu > System Preferences, click Time Machine, then select “Show Time Machine in menu bar.”) Select one or more items that you want to restore (individual folders or your entire disk), then click Restore.
If you use Time Machine to back up your Mac, you can recover your files if the operating system or startup disk is damaged. To do this, you must first reinstall macOS on your Mac before you can restore your files using your Time Machine backup. Read on for more information.
Reinstall macOS. Your operating system files are kept separate from your personal files in a sealed system disk. However, some actions, like erasing or inadvertently damaging a disk, require that you restore your iMac. You can reinstall macOS and then use Time Machine to restore your personal files from your backup. With macOS Big Sur, there are several ways to restore your Mac. You may be required to install a newer version of macOS than what your computer originally came with, or what you were using before the disk was damaged. To learn more about these options, see Time Machine troubleshooting on Mac in the macOS User Guide and the Apple Support article What to do before you sell, give away, or trade in your Mac.