Let’s backup that bestie! Ever get to a really good stopping place on your project… but then you fly too close to the sun and it just stops working and you can’t remember all the changes you made and/or rolling them back just seems like a monumental task? Or did you do what I did and take an upgrade a little too far? Well, recently I did this very thing while working with an otherwise wonderful robot arm kit from Yahboom. In short, I updated protobuf to use the Viam server software and in the process didn’t realize that the Yahboom applications required an older version of protobuf. Fortunately, rolling it back brought everything back online for the default app… but now I want to also be able to use it with Viam. So, my plan is to make a backup copy of the currently working stock software from Yahboom, and keep that MicroSD card handy, but also have an experimental MicroSD card where I can run the new version of protobuf and get this robot arm talking to Viam! The best of both worlds… then I also started thinking about how sometimes MicroSD cards just go bad and it’s a good idea to keep backups anyway. So, that’s what inspired this little guide.
Please understand that this is like all things on the Robot Besties website: a work in progress. We’ll soon have our comments section ready for your suggestions, recommendations, and improvements!
Raspberry Pi MicroSD Card Backup Option 1: Command Line
- Pros: No need to install additional software
- Cons: SLOW, “kinda” advanced, requires a MacOS or Linux system, may use a lot of disk space on your computer if the MicroSD card you’re using is large.
I referenced the guide here: https://howchoo.com/pi/create-a-backup-image-of-your-raspberry-pi-sd-card-in-mac-osx/, but made some changes.
- Safely shut down your Raspberry Pi project and remove the MicroSD Card.
- Place the MicroSD Card into an adapter or reader for your computer
- Open the terminal program and enter the following:
diskutil list
- Look at the results to find the correct volume, depending on your setup, you’ll see a few /dev/disk(number) entries. Look for the one which has “Windows_FAT_32 system-boot” In my example below:
- Depending on how your permissions are set up on your computer, you may need to go ahead and create the destination file before proceeding. In my case I named a file YahboomRobotArm.dmg in my user directory. Unless you have changed directories in terminal, you’re likely in your user directory already. You can check to see what directory you’re currently in by typing the “print working directory” command:
pwd
- Create an empty file in your directory of choice, in my example, I’m going to remain in my user directory with the following command. Use a filename of your choice, but on MacOS be sure that the extension is .dmg :
touch YahboomArmBackup.dmg
- Now that the file is created, it’s time to start the process of actually backing up the MicroSD card with the following command:
sudo dd if=/dev/disk4 of=YahboomArmBackup.dmg
Please note that this process will take a while depending on the size of the MicroSD card and your computer. The cursor may just sit there and blink (or not, in my case it just sat there in gray) until the process is complete. This could take 15-60mins or more. I opened a second terminal window and typed
ls -l
periodically to see that the file is getting larger.
- When the process was complete, I just closed the terminal and ejected the SD card normally from my Mac by clicking the “eject” icon next to the drive in the Finder.
- Now, you have a .dmg file you can use for flashing onto another MicroSD card using balenaEtcher or your favorite SD/MicroSD card utility.
Raspberry Pi MicroSD Card Backup Option 2: Using Software Tools
Step 1: Gather the necessary items:
- Raspberry Pi with an SD card inserted
- A computer with an SD card reader
- An SD card reader (if your computer doesn’t have one)
- An external storage device (USB drive or hard disk) with sufficient space to store the backup
Step 2: Install the Required Software
Before proceeding, ensure that you have the required software installed on your computer. We recommend using the open-source application called “Win32 Disk Imager” for Windows users and “Apple Pi Baker” for macOS users. These tools simplify the backup process and are widely used within the Raspberry Pi community.
Step 3: Connect the SD Card to Your Computer
Remove the SD card from your Raspberry Pi and insert it into the SD card reader on your computer. If your computer doesn’t have an SD card reader, use an external SD card reader instead.
Step 4: Launch the Backup Software
Open the backup software you installed in Step 2. Ensure that the software recognizes the SD card by selecting the appropriate drive letter or device name.
Step 5: Select the Backup Destination
Connect your external storage device (USB drive or hard disk) to your computer. In the backup software, select the destination folder where you want to save the backup file. Ensure that the destination has enough free space to accommodate the backup.
Step 6: Start the Backup Process
In the backup software, click on the “Backup” or “Create Backup” button to initiate the backup process. The software will create an image file of your Raspberry Pi’s SD card, including the operating system, files, and configurations.
Step 7: Wait for the Backup to Complete
The backup process may take some time, depending on the size of your SD card and the speed of your computer. Be patient and avoid interrupting the process to ensure a successful backup.
Step 8: Verify the Backup
Once the backup process is complete, it’s crucial to verify the integrity of the backup file. Most backup software provides an option to verify the backup against the original SD card. Use this feature to ensure that the backup is accurate and complete.
Step 9: Safely Eject the SD Card and External Storage Device
After verifying the backup, safely eject the SD card from your computer and remove the external storage device. This step ensures that no data is lost or corrupted during the removal process.
Congratulations! Your Project is Backed Up!
Creating a backup of your Raspberry Pi’s MicroSD card is a crucial step in safeguarding your data and system configurations. Remember to regularly update your backups to reflect any changes or updates made to your Raspberry Pi.