How to Backup & Restore your Raspberry Pi 4
- February 11, 2020
- Posted by: Naveen PS
- Category: Learn Technology in 5 minutes
In this blog, we will show you how to backup and restore the microSD card of your Raspberry Pi 4 in both Mac OS and Windows. You might be wondering, What is the need for doing this?
One apparent reason is to have a backup if something fails in the system. Whenever you are doing a long haul project like let’s say a machine learning or image recognition project, at one point or another, you are bound to face a software or hardware related error. Most of the time, it will be a hardware related issue, like a corrupted microSD card or an unstable overclocking. You know how annoying it can be to start from scratch. But we can fix that by backing up.
So shall we start?
After shutting down your Raspberry Pi 4, remove the micro SD Card and connect it to your PC with an adapter or a card reader.
I will show you the backup and restore procedure for both Windows and Mac users.
For Windows, you need to download a software called Win32 disk imager from this link: https://sourceforge.net/projects/win32diskimager/
After installing, open the application. In the Win32Disk imager first, select the boot drive of your MicroSD Card, Now click on the folder icon and select the directory you want to save the image file. And name it such that it is followed by the image extension “.img”. Leaving all other options as default, click the “read” button.
Now the backup is started. Have a cup of coffee and come as this might take some time depending on your micro SD Card. Once finished, you will be greeted with a popup saying “read successful”. Now you have got yourself a backup of your Pi 4 micro SD Card.
Now to restore the image file, you can use the same software itself. To restore the old image, click the folder icon, and select the proper image. Then connect a freshly formatted microSD Card and click the write button. The writing process will take considerably more time than the reading process, so be patient.
Now let’s look at how to do the same in Mac OS. Open the terminal in Mac and type the command
diskutil list to list all the storage devices.
Identify your micro SD card by looking under NAME and SIZE and verify the correct volume. Now type the following command, to create a disc image of your microSD card on the Desktop:
sudo dd if=/dev/rdisk3 of=~/Desktop/raspberrypi4.dmg
Don’t forget to change the disk volume name to the one you saw on your terminal earlier. The process to clone the SD Card may take some time, and you will not be shown any progress in the terminal, while the SD Card is being copied. You will, however, be shown a message when the process is complete.
To restore an image to the microSD Card. Insert a blank microSD card on your Mac. Locate the volume of the disk with the
diskutil list command like earlier. Now, use the following command to clone the disk image saved earlier to the new microSD Card.
sudo dd if=~/Desktop/raspberrypi4.dmg of=/dev/disk3
This process can take some time, and no progress will be shown. Don’t worry, wait patiently. Once completed, pop in the micro SD Card back to revive your Raspberry Pi 4 to the old state.
You have now successfully learned how to backup and restore the MicroSD card of the Raspberry Pi 4 in Windows and Mac Systems.
Learn Technology in 5 Minutes is a unique video series aimed at demystifying cutting edge technologies in the field of AI, IoT & Embedded Systems. Invest just 5 minutes of your time everyday and within a year you will have wide breadth and depth of knowledge on various topics.