MacOS
Within MacOS you can built a disk image in Disk Utility. This creates an Apple Disk Image (.dmg) file from which you’ll be able to restore from.
The .dmg file can then be mounted on any macOS system and will appear as a normal file system. You can then copy files from that image.
You can also use the restore feature in Disk Utility to restore all of the information from the .dmg.
Linux
The dd
command is built into Linux to allow for convert and copy files and backup and restore partitions.
Third party utilities are also available to assist in imaging drives, such as GNU Parted, and Clonezilla.