Why bother backing up your SD card?
There is some new information (September 2016) concerning Raspbian images and methods of SD card flashing that may be useful to you. How to flash an SD card with >4GB files
I had a difficult time getting the new Raspbian image up and running. That wasn’t because there was anything wrong with it. It was because I am in an unusual position. I’m away from base without my normal Samsung HDTV/monitor, and without ethernet, so I’ve been running my Pi “headless” via ssh and VNC, using wifi.
I’d also brought with me one of the Neewer HDMI-VGA adaptors that I’ve tested successfully on a couple of monitors. We have a TV here with a VGA input, so I figured this would be OK if needed (and it works fine with Wheezy beta – although I’m not using it).
So, when the new Raspbian image was released, I flashed a new SD card (well I overwrote my Arch card as I haven’t used it since I got FUSE working on Debian). Obviously I couldn’t ssh into a new installation until I’d installed the wifi dongle drivers (no ethernet). So in order to do that I needed to attach a screen. This is where the trouble started. With the Neewer HDMI-VGA adaptor attached, the new image failed to boot. Just the red power LED and nothing else (the same as happens when you have a corrupted SD card).
I eventually got it to work by removing the Neewer adaptor, powering up the pi, waiting until the green OK led started flickering and then attaching the Neewer, after which I could see enough of the display to get through the “first boot” screens. The timing was a bit hit or miss, but eventually I got the screen displaying properly by tweaking settings in the /boot/config.txt file. After that I installed the wifi drivers and it was bye bye screen. :laugh:
So how does this bring me to backing up? Well, I like to mess about with my installation trying new things. In the past if I messed up, I just reimaged the SD card and started again. In this case, I don’t want to go through that process again :cry: so I figured I’d back up an image of the fully working SD card before I break it. Now I’m going to show you how to do the same.
You may well have used Win32diskimager already to write your SD card. I’ve had great success with this using version 0.5. Download here. Then unzip the file win32diskimager-binary.zip, then double-click Win32DiskImager.exe in the unzipped folder called win32diskimager-binary. Click Yes to confirm you want to run the program. Then it will start. Once you’ve established that it works, close it down and plug in your SD card. Then restart the program. Choose the drive you want to copy the image from (in my case F:\).
Then click on the folder icon and choose where to place your backup image – also give it a name e.g. backup345.img then click save
Then, the counter-intuitive bit. You have to click READ so it will read the SD card and write the image in the location you just chose.
It might take a while. It took about half an hour to do an 8 Gb card. It will back up the whole image including empty space on the partitions. You can compress this later with winzip or 7zip, but if you want a really compact image you’ll have to shrink the partitions first and then regrow them later. Since messing with partitions is potentially disastrous – and what you’re trying to do here is protect your installation – I would recommend not shrinking the partitions. If you want to make an image to share with others by download, you could always do this AFTER you’ve backed up the data and then make another, more compact, image.
Use DD with extreme caution. It’s nicknamed Destroy Disk for a good reason. It’s a very powerful command and you can all too easily wreck your hard drive by being careless here.
dd if=/dev/sdb of=/path/to/backupfile.img
where sdb is the SD card location and backupfile must be a file name.img and not a disk identifier (or instead of writing a single file to the hard disk it will try to rewrite the whole disk).
This will copy the entire contents of sdb and dump it into the file backupfile.img
If you’re not sure what your SD card’s identifier (sdb, sdc etc.) is you can use the tail command as we did in the attaching a USB stick post.
Use DD with caution. You have been warned! If you have access to both, I’d say using the Windows option is safer, unless you really know what you’re doing (in which case what are you doing here? :-P )
Enjoy peace of mind now you know how to back up your Raspberry Pi Operating System SD cards.