Back up and restore your Mac
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 iMacβwith an external storage device connected to your iMac. Time Machine can also back up your Mac contents to supported network volumes. For a list of devices supported by Time Machine, see the Apple Support article Backup disks you can use with Time Machine.
Files in iCloud Drive and photos in iCloud Photos are automatically stored in iCloud and donβt need to be part of your backup. However, if youβd like them to be, do the following:
iCloud Drive: Go to Apple menu
> System Preferences. Click Apple ID, then click iCloud. Uncheck Optimize Mac Storage. The full 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.
Tip: You can use a shared Mac thatβs on the same network as your iMac as a backup destination. On the other Mac, go to System Preferences > Sharing, then turn on File Sharing. Add a shared folder, secondary click (that is, right-click) the folder, choose Advanced Options, then click βShare as Time Machine backup destination.β
Set up Time Machine. Make sure your iMac is on the same Wi-Fi network as your external storage device, or connect your storage device to your iMac. Click the System Preferences icon in the Dock, click Time Machine, then select Back Up Automatically. Select the drive you want to use for backup, and youβre all set.

Time Machine:
Automatically backs up your entire iMac, including system files, apps, accounts, preferences, music, photos, movies, and documents.
Remembers how your computer looked on any given day, so you can revisit your iMac as it appeared in the past or retrieve an older version of a document.
Lets you restore your entire system from a Time Machine backup. So if anything happens to your iMac, your files and settings are safe and sound.
Learn more. See Back up your files with Time Machine in the macOS User Guide.