![]() The prefix “r” points to the card’s raw storage space to speed up the process. “if” stands for “input file” which in this case is the SD card. Type this command to make the image file. Make and compress image file of the SD card The name will be something like: /dev/disk1Ģ. Type this command in the terminal on your Mac: $ diskutil list WARNING 2! This method will not work with Noobs, only clean Raspbian. If you type something wrong, you may damage your computer. WARNING 1! Be sure to check your values carefully like the “/dev/disk1”. Then turn off the Pi and put the card into your Mac. First set up your Raspberry Pi to your liking. A new mybullseye.img will be created on the next run.You can use the Apple-Pi baker application to clone the SD card, or do it manually like described here:Ĭlone your Raspberry Pi SD card with the “dd” command line tool. If you want a fresh full backup for some reason, rename the file mybullseye.img in the computer to something else. Make sure the computer has sufficient disk space to keep at least one copy of the Pi disk image. In the ComputerĬreate a folder PiDiskImage where you will be keeping the Pi SD card image backup. This will run as root on 1st and 15th of each month at 11 PM. The following line: 0 23 1,15 * * /home/username/bin/pibackup.sh If all goes well you will have an image file, /path/to/PiDiskImage/mybullseye.img Finally automate the backup processĪdd in root’s crontab using the command: sudo crontab -e Run the script to see if it works and create the initial image backup. Replace mybullseye.img with the file name of your choice.Replace /path/to/PiDiskImage to the actual folder in the computer where the image will be saved.Replace username2 with the username of the computer user.Replace username1 with the username of the Pi user.Make the following changes to the above script: home/username1/bin/image-utils/image-backup /mnt/backup/mybullseye.img usr/bin/sshfs :/path/to/PiDiskImage /mnt/backup # Purpose: Backup the whole SD card running Pi to the computer Unzip the image-utils.zip file in ~/bin/image-utils/ sudo mkdir /mnt/backup Install sshfs with the command: sudo apt install sshfsĭownload RonR-RPi-image-utils-master zip file from We will use sshfs to mount the remote folder in the computer in the Raspberry Pi, so that the SD card image can be written directly in the remote folder. The Pi user should be able to ssh into the computer using key based authentication.The Pi and the computer connected by LAN or WLAN.A Raspberry Pi running Buster or Bullseye.In other words the script modifies the existing backup image file. On subsequent runs the script will add to the existing image any changes made in the Pi SD card. This image will not contain empty space and thus will be smaller than the full size of the SD card. This script when run for the first time will create a full disk image of the SD card from which the Pi is running. I use this to backup my Raspberry Pi SD card to my Linux computer every 1st and 15th of the month. ![]() Pigz compress image to 5.5 GiB zip file: 2.5 mins ![]() Move shrunk image to shared Windows folder on PC: 4.5 mins Pishrink shrinks image to 11 GiB: 4.5 mins I enabled OpenSSH on Windows 10 and after a bit of fooling around I got the Rpi to use sshpass to command the Windows PC to do the compression, so the whole thing - dd backup - image shrink - image compress to zip, happens from one script on the Pi and takes around 25 minutes:ĭd makes 30 GiB image on USB3 external hard drive: 12 mins On my i7 4790 PC with 16 GB RAM the images compress 11 GiB to a 5.5 GiB zip archive in around 2 minutes 30 seconds. This seemed OK until I found out about a parallel compressor called pigz. The finished image ends up in a Windows shared folder mounted on the Pi so I tried WinRar and 7zip command line utilities on Windows to do the compressing. From a 32 GB sd card I am making 11 GiB images which the Pi takes around 50 minutes to compress to around 5.5 GiB using not very severe compression options. it is painfully slow if you let the Pi hardware do the compression. ![]() It is nice to compress the image to a zip archive (Balena Etcher can use these) but. This means you could flash a smaller card than the original, provided the shrunk image size is smaller than the new card. It is useful because after using dd to make the image it optionally shrinks the image with resize2fs to a little above the data size, and also can optionally insert a run-once command into the image to make Raspbian expand the file system when the image is flashed to a card and used for the first time to boot a Pi. I have been successfully using a script called pishrink by Drew Bonasera ('Drewsif') to back up a headless Raspberry Pi 4 (it works for all models).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |