Getting Started with Python for the Internet of Things
上QQ阅读APP看书,第一时间看更新

Using the tools to back up your SD card in case of failure

You can use Win32 Disk Imager to make a full backup image of your SD card by inserting your SD card into your reader, starting the program, and creating a filename to store the image in. Simply click on the Read button instead to read the image from the SD card and write it to a new image file.

To make a backup of your system, or to clone to another SD card using Raspberry Pi, use the SD Card Copier (available from the desktop menu via the Accessories | SD Card Copier).

Insert an SD card into a card reader into a spare USB port of Raspberry Pi and select the new storage device, as shown in the following screenshot:

SD Card Copier program

Before continuing, the SD Card Copier will confirm that you wish to format and overwrite the target device and, if there is sufficient space, make a clone of your system.

The dd command can similarly be used to back up the card, as follows:

  • For Linux, replacing sdX with your device ID, use this command:
sudo dd if=/dev/sdX of=image.img.gz bs=1M  
  • For OS X, replacing diskX with your device ID, use the following command:
sudo dd if=/dev/diskX of=image.img.gz bs=1M
  • You can also use gzip and split to compress the contents of the card and split them into multiple files, if required, for easy archiving, as follows:
sudo dd if=/dev/sdX bs=1M | gzip -c | split -d -b 2000m - image.img.gz
  
  • To restore the split image, use the following command:
sudo cat image.img.gz* | gzip -dc | dd of=/dev/sdX bs=1M