Connect with us

How To

Backup Raspberry Pi – How to Backup Your Raspberry Pi SD Card?

Published

on

Backup Raspberry Pi

It is always recommended to back up the data of your device for safety purposes because redoing one that you have already worked hard on. since the Raspberry Pi uses the microSD card as the primary storage, it is very easy to back up the Raspberry Pi on any platform. This article helps you to backup Raspberry Pi SD card on Windows, Linux, or macOS and how to restore it from that backup too.

Backup Raspberry Pi
Backup Raspberry Pi

Shut down the Raspberry Pi safely (The shutdown process varies based on the OS you are running –  for Raspbian, it’s just sudo shutdown now in the command line) and remove your microSD card. then put the card in your computer’s card reader slot and follow the steps given below.

Related: How to Play Retro Games on the Raspberry Pi Using RetroPie?

How to Backup Raspberry Pi SD card on Windows

Step 1: Open the Win32 Disk Imager, It is the application for SD card writing and re-writing, and we will use it here, too. If you don’t have this app, you can download it here.

Backup Raspberry Pi
Backup Raspberry Pi

Step 2: Set the drive and destination folder,

In Win32 Disk Imager, use the drop-down menu labelled Device to choose the drive which matches to your SD card. then click the button with the folder on it and then select the folder that you wish to backup to. Type a new filename into the File name: box – this is the file name for your backup. The default file type will be .img by default, which is good because that’s what you want. You can go ahead and hit Open now.

Step 3: Write the file,

Now simply hit the Read button-which should be simple enough to do, especially because Win32 Disk Imager will grey out the Write button when it sees the .img file that you have chosen doesn’t exist yet. Your work here is done. Now the Win32 Disk Imager will do the rest. Just Eject the SD card when it’s all done.

Restoring your Backup Raspberry Pi on Windows

Suppose if you lost all the data in your Raspberry Pi card and you need it to restore back, then you can follow the given steps. Now you have to put the SD card in and select the proper drive from the drop-down window. Now you have to select the .img file and it already exists in your backup. So that you can click the Write button. That’s exactly what you should hit, of course, and once you do Win32 Disk Imager will replace whatever is on the SD card with the backup disk image Easily.

How to Backup Raspberry Pi SD card on macOS?

Step 1: Open the Terminal and find your SD card, then Open up the Terminal on your Mac and enter the below command:

diskutil list

This is going to list every drive on your Macbook, but you can identify your SD card easily by roughly selecting the right size. Note down the location of the drive.

Backup Raspberry Pi
Backup Raspberry Pi

Step 2: Backup your SD card in Terminal, Now that you know where your SD card is, you can refer it in the command asking the Mac to back it up. Here is the command:

sudo dd if=/dev/disk1 of=~/MyPiBackup.dmg

The first thing you have to look at is the location, which may differ for you. The second part is the file name of the image we are creating, and you can feel free to change that to whatever You have to wait a while and won’t get a progress bar or anything to watch. After some time you will be all set with the backup copy of your Pi’s SD card.

Restoring the Backup Raspberry Pi on MacOS

If something went wrong with your Raspberry Pi, you can restore the Raspberry Pi’s SD card, and you have to open the terminal back up and once again run the diskutil list. Track down the SD card again, and enter this command ( with the location of your replacing the part in bold):

diskutil unmountDisk /dev/disk1

Now we can re-write the SD card from our backup.

sudo dd if=~/MyPiBackup.dmg of=/dev/disk1

Again the bold parts might look different for you: the first is whatever you named your backup, and the second is the location of the SD card. And as with creating the backup, this will also be a long and lonely process. Once the SD re-write is completed, you can eject your SD card.

sudo diskutil eject /dev/rdisk3

That’s all.

Related: How to Connect Raspberry Pi to WiFi Network?

How to back up your Raspberry Pi’s SD card on Linux

Step 1: Find your Raspberry Pi SD card, Enter the following in the command line:

df-h

That will list all of your drives. You have to find the SD card of your Raspberry Pi. Now Note down the location listed in the Filesystem column.

Backup Raspberry Pi
Backup Raspberry Pi

Step 2: Backup the SD card in Terminal, Here the Linux and macOS also share the same step in this guide. Just enter the following command

sudo dd if=/dev/sda of=~/MyPiBackup.img

Here the two parts will vary, the first should be whatever the location you wrote down in Step 1, and the second can be any file name you want to use for your backup. And you have to wait for sometime as with Mac, When it finally finishes, then you will have your backup.

Restoring your Raspberry Pi on Linux

Follow the steps given below to restore the SD card of your Raspberry P. Back to the command line. Find your SD once again with the df-h. then unmount it with this command:

sudo unmount/dev/sda1

Backup Raspberry Pi
Backup Raspberry Pi

Related: How to Play Retro Games on the Raspberry Pi Using RetroPie?

Swap out the bold part for whatever the location is listed for your SD card under the Filesystem in a list the df-h command returned. Now you can run the command, once again swapping out the bold parts (first is the file name that you gave your backup, and the second is the location of your SD card)

sudo dd bs=4M if=~/MyPiBackup.img of=/dev/sda

Again you have to wait for sometime and return to find your Pi’s SD card restored. These are the ways to Backup Raspberry Pi SD card and restore them.

Thank you for reading this post.

Advertisement

Facebook

Trending