sudo dd if=/dev/mmcblkX of=/path/to/image.img status=progress
===== Backup with gzip =====
sudo dd if=/dev/mmcblkX | gzip -c > /path/to/image.img.gz
====== Restore with dd ======
sudo dd if=/path/to/image.img of=/dev/mmcblkX status=progress
===== Restore with gzip =====
gunzip -c /path/to/image.img.gz | sudo dd of=/dev/mmcblkX
===== Restore xz-image =====
xzcat /path/to/image.img.xz | sudo dd of=/dev/mmcblk0 status=progress