Take the SDcard out of the Pi and insert into your Linux PC via a card reader:
Run the following command to find what the device ID:
dmesg
My SDcard is /dev/sdd. Run the following command to back up the SDcard:
sudo dd bs=4M if=/dev/sdd | gzip > ~/piBackup.gz
To restore the backup on SD card:
sudo gzip -dc ~/piBackup.gz | dd bs=4M of=/dev/sdd