We must remember to backup the RPi’s SD card! First of all, SD cards were never meant to be used the way they are in the RPi. They were meant for data blocks written infrequently by cameras. USB flash drives are better suited for RPi-kind data storage than SD cards.
Secondly, the RPi’s data bus is very finicky when it comes to the input voltage. I was trying to power my Pi using a portable mobile phone charger by HooToo (hootoo). Though it’s rated output is 2A, I think I connected and disconnected it multiple times by mistake without a clean shutdown. This corrupted my sd card! But I am not talking about just data corruption – it physically corrupted it such that it cannot even be read anymore.
So the lesson learnt is – backup as much as possible!
The simplest way I know is to use a Linux computer and the ‘dd’ command. Here are some steps to follow:
Make sure there’s enough space on the local drive!
Check partition names:
sudo fdisk -l
Unmount SD-card partitions before reading or (esp.) writing!
sudo umount /media//root
Use this for backup:
sudo dd if=/dev/mmcblk0p6 of=root.img bs=32M
(The block size could also be 4M)
Use this for restore:
sudo dd if=root.img of=/dev/mmcblk0p6 bs=32M
For those who want to use windows for backup, the standard win32diskimager tool is great. But note that it clones the entire SD-card. You cannot select individual partitions.