Time Machine keeps hourly backups for the past 24 hours, daily backups for the past month and weekly backups after that, until the disk is full. It's the easiest way to protect everything on your Mac.
1Choose a backup disk
Use an external drive at least as large as your Mac's storage, ideally two to three times larger. Time Machine formats it as APFS. Alternatively, back up over the network to an SMB share on another Mac (File Sharing) or a NAS that supports Time Machine over SMB.
Apple's older network backup options, AirPort Time Capsule and AFP shares, aren't supported for Time Machine on macOS 27. Move network backups to a Time Machine-compatible SMB share. Check Apple Support if you're unsure whether your NAS qualifies.
2Turn on Time Machine
Go to System Settings > General > Time Machine, click Add Backup Disk (or +), choose the disk and turn on Encrypt Backup. Set a password you'll remember, because without it the backup is unreadable. Use Options to exclude folders you don't need backed up.
3Check it's working
tmutil destinationinfo
tmutil status
tmutil latestbackup
tmutil listbackups
tmutil startbackup # start one now
4Restore files
Open the folder that contained the file in the Finder, then choose Browse Time Machine Backups from the Time Machine menu bar item (or open Time Machine from Applications). Use the timeline on the right to go back, select the file and click Restore.
5Restore a whole Mac
On a new or erased Mac, use Migration Assistant during setup and choose to transfer from a Time Machine backup. To restore an entire system to an earlier state, start up in macOS Recovery (see the troubleshooting tutorial) and use the Time Machine restore option there.