Ah, ok you were referring to my setup. Sorry didn’t catch you.
But, yes that means OSMC can survive without xattrs
In my case, and due to the small size of the Pi system, I opted for a simple gzip dd image, made in off-line (shutdown osmc, place the sd card in the PC, do the backup).
Have already restore it for several times and work just as the perfect system snapshot.
I suggest to run something like the following command in a PC linux:
- Backup:
dd if=/dev/sdb bs=512 | gzip -c > backup.img.gz
- Restore:
gzip -d -c backup.img.gz | dd of=/dev/sdb bs=512
(assuming the sdcard is /dev/sdb in the pc)
This also works in windows using cygwin (just need gip.ex, dd.exe, and cygwin dll’s).
I’ve choose to use a 16GB micro sdhc, and partitioned it with the 2 needed osmc partitions (1 with fat for boot, and 1 with ext4).
Limited the size of the 2nd partition to stop around the 4GB boundary, and so making smaller images with (previously validated the correct partition ending sector+1 with fdisk):
dd if=/dev/sdb bs=512 count=8302592 | gzip -c > backup.img.gz
With this aproach I have compressed images with around 1.6 GB - 10 mins to backup, 20 mins to restore (depending on the sdcard and the reader).
Yes, that’s how to do it with dd. But ppl were asking how to do it automatically.
you can always schedule a dd and do the backup online.
not sure what would happen to the image about its integrity in case of a restore - but I could do the test.
simply copying files online might also not be the proper approach - during the copying process files may change and again, I would not trust the backup integrity …
No, dd is not safe to use on a r/w mounted partition.
If files are changed while dd is running you will end up missing files or parts of files rendering your backup useless and possibly so corrupted it won’t restore at all.
Consider using dd while kodi is running. If kodi writes to its database (a large and likely fragmented file) dd may have copied the first part of the database already and will not know kodi changed it. The later part of the database might be on a part of the disc that dd hasn’t copied yet, so it correctly gets that bit. Result: corrupt database.
Which is unfortunately why using dd to back up the root partition of a running OSMC system is not a good approach. Shutting down a Pi and pulling the SD card ensures a (logically and physically) consistent image, but this method isn’t possible on a Vero.
Yep. That’s it.
That’s Why I’ve suggested the offline approach - it is rather quick (more or less) but trustworthy:
It’s the best shot for osmc in a Rapsberry PI
does that mean a root installation on the internal storage can be backed up to nfs and then restored without problems even if xattrs are not saved?
cheers b
Seems so
I’m sorry for a stupid question (again) but given that I can’t run this on the pi itself as it boots from the sd card, how do i run this on a windows pc? Do I need a liveboot CD or usb or is there a clever way of getting the backup onto a blank microsd?
You need a linux system - yes, a liveboot CD will do it or boot the Pi with any version of OSMC, Raspbian or whatever. Copy osmc-restore to the root directory on the backup disc and chmod +x osmc-restore
. Plug in the backup disc and the SD card in a card reader (USB card reader if on the Pi). Then run
/path/to/script/osmc-restore /path/to/backup/dateofbackup
.
if you have difficulty in accessing a linux system, you can run from windows using cygwin.
An example of backup:
dd.exe if=/dev/sdb bs=512 count=8302592 status=progress | gzip -c > backup.img.gz
For this to work you’ll need cygwin’s dll files, dd.exe and gzip.exe.
If there is interest in this, I can share these files and the batch files for backup and restore to run from within windows without the need to install the entire cygwin distribution ( just 4,91 MB)
sudo bash osmc-restore osmc-restore: line 14: syntax error near unexpected token
then’ osmc-restore: line 14: BACKUPDIR="$1" MEDIA="$2" FORMAT=0 if [ "$1" == "-f" ]; then' osmc@osmc:~$
Thanks for the advice. I got a USB SD card reader so as to do it all from the pi.
Unfortunately this is the output (I know I just invoke the script here, but it’s the same if I invoke it with the arguments “backupdir” and “media” as well
You must have copied it wrong. that is line 25 (not 14) in the script and it doesn’t have a ’ after then.
Quite right, I had copied and pasted on my phone. Downloading the zip fixed that.
I can’t get it to work though, this is the output
osmc@osmc:~$ sudo /home/osmc/osmc-restore /media/f03a3de0-b985-4320-8039-f555568fc686/osmcbackup/2017-05-18
sdb 115.3G disk
sdc 7.5G disk
sda 1.8T disk
mmcblk0 7.4G disk
Please enter the device name of the media to restore to … sdc
/dev/sdc is mounted but not removable - are you sure (Y/N)?
Can't find a suitable vfat partition for boot
754604KiB in system backup
Can't find a suitable ext partition for system
Time to restore: 00h:00m:01s
osmc@osmc:~$
The script expects the card to be already formatted for OSMC and is looking for a FAT partition of a certain size and an ext partition. If it’s not formatted for OSMC (ie factory formatted or Raspbian, LE, NOOBS, etc), use the -f option to format it.
If you think it is formatted correctly, lsblk -blo NAME,SIZE,TYPE,FSTYPE | grep sdc
will give me some clues.
Many thanks!
After installing parted, it formatted and restored the backup.
It doesn’t boot though.
I’ll redo it later and post the output.
Can you check the boot partition has its LBA flag set? I did have some problems with that but thought I’d fixed it.
Apologies for being a needy noob.
I’m attempting to backup to NTFS ex-hdd. Script is giving the follow error:
Mon Jul 10 11:18:36 SAST 2017 Backup version 0.1.6a
Going to back up to /media/Big\ Bertha/osmcbackup/2017-07-10 (unless I can't find it).
mkdir: cannot create directory 'backup': File exists
mount error: could not resolve address for SERVER: Unknown error
mkdir: cannot create directory 'backup': File exists
mount: can't find /media/Big Bertha/backup in /etc/fstab
looking for mounted media
media for /media/Big\ Bertha/osmcbackup not mounted in /media or /mnt or not formatted for linux
I have amended the script like so:
### if the backup medium is not formatted for linux permissions (eg ntfs)
# you could make an ext4 filesystem image and mount it with:
cd /media
mkdir backup
mount -o loop /media/Big\ Bertha/backup