CloneSDCard

1. Use diskutil to discover which is input and output sd card

diskutil list 

2. Unmount input and output. Note that disk2 and disk3 are placeholders, replace with the drives discovered in step 1

diskutil unmountDisk /dev/disk2   # input
diskutil unmountDisk /dev/disk3   # output

3. Use dd to perform the clone

sudo dd if=/dev/disk2 of=/dev/disk3 bs=4m

Creating an img file is similar

3. use dd to create the file

sudo dd bs=4M if=/dev/sde of=/home/username/MyImage.img

4. use dd to restore the file

sudo dd bs=4M if=/home/username/MyImage.img of=/dev/sde

or use Etcher

References: