Create a disk image for recovery
Boot to the Recovery HD by holding ⌘R on boot. Choose Disk Utility, select your system partition from the sidebar, then select File → New Image → Image from "&lt;partition name>". Follow the instructions to choose a save location.



To restore your image, boot to Recovery, create a partition of equal size or larger than the image you saved (if necessary), then select that partition and choose the Restore button on the toolbar.



The options are greyed out in the above screenshots as I am not booted to Recovery.

The Recovery System is part of macOS and should already be a separate partition on your startup disk (hidden in Disk Utility). You can use Internet Recovery with ⌥⌘R on most Macs to perform a NetBoot-esque recovery using Apple's server, for example if you have a fresh HDD that you want to restore on to.

If you want to put a Recovery System on an external disk or secondary internal disk, you can use Recovery Disk Assistant (1 GB required).