lzkelley / bkup_rpimage

Script to backup a Raspberry Pi disk image
GNU General Public License v3.0
162 stars 54 forks source link

Backup a USB HD partition #10

Open AlbertoLopSie opened 5 years ago

AlbertoLopSie commented 5 years ago

Hi,

I've just set up mi RPi to boot from SD (mmcblk0) and innmediatelly mount the rootfs from a USB HD as described in HOWTO: Move the filesystem to a USB stick/Drive. I also added a couple of additional partitions to mount /var/log, /data and a /backup mountpoints

I want to schedule daily backups of /boot (on SD) and / (on USB HD) and store the images on /backup in order to be able to burn a new SD and boot from it in case of HD failure.

Your script assumes the source partitions are on /dev/mmcblk0 and use that device to get partition sizes and types to create the target image. However, it then rsync's from / and /boot, that in my system are in the USB HD /dev/sdc.

How do I tell the script to take those params from the proper places? (/dev/mmcblk0 and /dev/sdc2)

I'm also planning as the next step to boot directly from the USB /boot partition (/dev/sdc1 in my case) and remove the SD card from the RPi. I guess that in that case, the bkup_image script will have trouble to get the image geometry from an inexistent SD card.

Any hint? Thanks!

dolorosus commented 5 years ago

This script is not intended to make backups from any other source as the sdcard. Your usecase /boot on another device as / is a little special. In case this would work you will have a single file containing two filesystems from different devices.

But feel free to rip the relevant functions from this script. You have to

The resulting file can be transferred with dd to a SD card and should be bootable. BTW: The geometry of the SD card does'nt matter in this usecase.

ephestione commented 5 years ago

I have another proposition: if you cannot or don't want to use full USB boot (no SD card at all) you can try the bootcode.bin method, where you can keep the SD only to hold that single file, and then it will search for the first available USB drive for a boot partition containing a cmdline.txt: https://www.raspberrypi.org/documentation/hardware/raspberrypi/bootmodes/

That way you have /boot and / on same drive and can use this tool with no hassle, just like I do.