Backup osmc partition

Hi

Has anyone built a solution to do a partition backup of the osmc OS which could be saved to /sda1 for example, and from which a previous image could be easily restored?

Right now i remove sdcard, plug it into my windows pc and use a program called w32 copier (or something like that), but moving a card in and out of pi isn’t ideal.

I’m on Noobs, which i think boots up before osmc, and unless shift is pushed the pases the baton so to speak onto osmc. I seem to remember that when i got my wdpidrive that it came with some software (maybe like a dual boot) type of solution which if memory serves allows block level backup and restoration.

I don’t suppose there is a way of doing this with osmc, as it probably can’t do a block level backup of itself when running.

Any suggestions? Too ambitious perhaps?

Cheers, Geoff.

Backing up is fairly trivial, but NOOBS complicates things a bit more.

dd will let you do block level backup, just attach a USB drive and be careful with paths.

if my wdpidrive is sda1, then do you think this dd command would be close to the mark?

sudo umount /dev/mmcblk06

dd if=/dev/mmcblk06 of=/dev/sda1 bs=64K conv=noerror,sync

sudo mount /dev/mmcblk06

presumably the file name created will be something like mmcblk06.img?

Do you think i could put this in the bootloader so there is an option of pushing shift during startup and choosing this image file as the one to restore from? That would be slick-as!

Cheers, Geoff.

This will overwrite your wdpidrive completely, I don’t think this is what you want, or?

Also are you doing this from within OSMC or any of the other NOOBS OS you have installed? If you do it from within OSMC you will not be able to unmount /dev/mmcblk06

thanks.

I did not want to overwrite my pidrive. That would be bad.

Two questions:

  1. If I create a dir in sda1, would this work, for example; ‘dd if=/dev/mmcblk06 of=/dev/sda1/images_** bs=64K conv=noerror,sync’ I assume dd doesn’t require a ‘twin’ partition on my pidrive to work, and that directing dd to a dir would be sufficient

  2. If I entered recovery mode would this allow my access to the osmc partion and then run the dd command

I seem to remember my pidrive came with software what would create a disk / partition image, however this is long gone and I can’t remember what is was. Could I replace by current recovery partition software with an alternative which has a gui for image backup / restoration?

Cheers, Geoff.

Please read the manpages for dd carefully before you do any harm to your data. It is a quite dangerous tool in this regard.

You want to write the contents of your partition to an image file.

Please google how to do that.
If then still not sure post your proposed commands here again.

I foud the easiest and safest way to do this is to navigate the folder you’d like the backup to be stored in and the run (as root)

dd if=/dev/mmcblk06 conv=sync,noerror bs=64K | gzip -c > ./osmc_backup_$(date +"%Y%m%d_%H%M%S").img.gz

That way you know exaclty where the file is and it won’t overwrite anything.

3 Likes

Since a file system partition should be backup while it’s not running. So you stuck doing it on pc as you have done.
If you don’t want to move the SD card you need:

  • another OS to boot into
  • rsync to copy

Once running another OS:

$ sudo su
# apt-get install rsync

# mkdir /mnt/root
# mount /dev/mmcblk0p7 /mnt/root
# mkdir /mnt/usb
# mount /dev/sda1 /mnt/usb

# rsync -arv --exclude 'boot/*' /mnt/root/ /mnt/usb/

# umount /mnt/root
# umount /mnt/usb
# rmdir /mnt/root
# rmdir /mnt/usb

Even better, you can run OSMC from the USB you just copied to and use the SD card as a backup.
Get UUID then change /dev/ mmcblk0p6 to /dev/ UUID=value(no quote) in commandline.txt

# blkid

# mkdir /mnt/boot
# mount /dev/mmcblk0p6 /mnt/boot

# nano /mnt/boot/cmdline.txt

PARTUUID works with some other OSes but OSMC needs UUID only.

I really wouldn’t use rsync to create a full backup of a partition as it stores only the files, not the partition table. If you tried to restore that to a different SD card it wouldn’t necesarily work. rsync is great for backing up files, but it is not an imaging tool, it is essentially just a wrapper for cp.

The fact that the OP’s OSMC partition is mmcblk06 rather than mmcblk02means that he is working on a multi-boot system, so he can just boot to a different OS and run from the unmounted partition.

Partition table?

rsync?
Arch Linux Wiki - Full system backup with rsync

Multi OSes?
RPi NOOBS runs from 1 single OS up to many.
His blkid clearly showed 1 OS:

  • /dev/mmcblk0p1 - NOOBS BOOT
  • /dev/mmcblk0p5 - NOOBS SETTINGS
  • /dev/mmcblk0p6 - OSMC BOOT
  • /dev/mmcblk0p7 - OSMC file system

Lots about this here: Backing up sd card image on external usb drive - #10 by sam_nazarko

I still like methods with rsync or plain old cp as backup can be done from within the OSMC system and selective restore is possible.

Borg: Borg Documentation — Borg - Deduplicating Archiver 1.1.14 documentation
arm builds: https://borg.bauerj.eu/

Have fun!