It can take a long time to set up a Raspberry PI, then something goes wrong, the card cannot be read or the sucker will not boot and you get to start all over again. Backup ( which implies restore ) is one solution to this.
Backup used to be to tape, the stuff in the picture above. Picture from: https://commons.wikimedia.org/wiki/File:IBM_System...
Step 1: Tools and Materials
- Raspberry Pi
- PC ( with some tools we will install )
Step 2: Overview
The Win32 Disk Imager is a piece of software that is often used to load a OS on a Raspberry Pi. Many people also know that it can be used to read a SD card with an OS. This is the key to backup. However, the image you get is a big as the card. Most of mine are 16 Gig, and this is a fair amount of space, and over my LAN takes a fair amount of time to move around. So zip it. But many zip programs have a size limit smaller than 16 Gigs. Solution use 7-Zip which is fine at 16 Gigs. But how much compression do you get. On my Pi it says about 8 gigs free and this should compress out. In practice the compression went from 15.5 Gig to 3.2 Gig this is saving more than 10 Gigs. Note that 15 Gigs is pretty much all that a Google drive will give you.
Step 3: Set Up the PC and Use It
Similar software is probably available for other operating systems, but I will only cover Windows, in my case Windows 7
You can read about it use at: INSTALLING OPERATING SYSTEM IMAGES USING WINDOWS
For your backup this reference is as good as any I can write: TNET Raspberry Pi Pages .
This process is not quick, say about 1 hour, 16 gigs is big as SD card speeds.
Then install: 7-Zip is a file archiver with a high compression ratio. http://www.7-zip.org and 7-Zip the image, which again takes about an hour.
I put the image the zipped one, the other may be discarded, in its own directory. Then I add a readme.txt file that summarizes features of the OS, here is a sample:
Backup of Pi operating system -- see date on file from a 16 gig mini card expanded to use all of card, then 7-zipped build on os from from D:\_Source\rPi\PiBackups\Checkpoint1\cp1.img passId pi secret_not_really ip is fixed ... 175 Setup autoexec.py, logs on to nas on buff remote desktop xrpd synaptic samba multiple browsers best? chromnium arduino lots of python runs my terminal and irtools spyder mysql
Step 4: More
It would be nice to shrink the image for some purposes. Try Google. I found this. The Rantings and Ravings of a Madman: Script : Automatic RPi Image Downsizer
Gparted a Linux utility may help in resizing.
I also found that I could mount the card and access it using a virtual box version of Linux Mint. I had to put it in a USB reader not the SD card reader. Then I accessed it with Gparted. This was complicated enough that I did not go farther. Google will help you.
Gparted can also be installed and run on the Pi. Remember it can destroy your disk if you mess up.
Other sites on the web also suggest ways of resizing. In all cases I would have a full size backup and confirm the downsized image before deleting. Comment below on your experiences.