First, know your partitions:fdisk -l
Full backup of the image:
dd if=/dev/sdx of=/path/to/image
```or for compression (recommended):
dd if=/dev/sdx | gzip > /path/to/image.gz
To restore the backup you reverse the commands:```
dd if=/path/to/image of=/dev/sdx
```or when compressed:
gzip -dc /path/to/image.gz | dd of=/dev/sdx
The info is from [here](https://raspberrypi.stackexchange.com/a/312).