Backup SD card

This version is built for 32Bit-ARM CPUs with a Floating-Point-Unit (ARM v6 and v7).

1 Like

The v6 version works for arm 6/7. I use it regularly on my pi3. I backup /home/osmc and /etc. If your pi dies, a clean install of OSMC and then restoring the borg backup repo will get you back up and running asap. You would of course need to install any non-default programs that you use as well.

1 Like

I think wouldn’t bad to add /boot/{cmdline.txt,config.txt,preseed.cfg} or output of grab-logs -pOoab -P also.

Also wise backup choices!

Could you give me to look on your settings?
Thanks for your advices.

#!/bin/sh
REPOSITORY=/media/NextStar-Pi3/borg/

# Backup all of /home and /etc except a few excluded directories
borg create -v --stats --progress               \
    $REPOSITORY::'{hostname}-{now:%Y-%m-%d}'    \
    /home                                       \
    /etc                                        \
    /boot/config.txt                            \
    --exclude '/home/*/.cache'                  \
    --exclude /home/osmc/Music/streamripper     \
    --exclude '*.pyc'

# Use the `prune` subcommand to maintain 7 daily, 4 weekly and 6 monthly
borg prune -v $REPOSITORY --prefix '{hostname}-' \
    --keep-daily=7 --keep-weekly=4 --keep-monthly=6
1 Like

Sorry to resuscitate this thread, especially because my questions might not be 100% related to the original post.

I do backups of my system as well, using win32diskimage, it does the job. When I do something wrong and have to revert to a previous version it works fine, but now I’ve got a different challenge: I bought a faster micro sd card, wanted to migrate the existing card to the new one (keeping all the same config), but even though they are both 32gb, the new one is apparently slightly smaller than the old one… How can I remove to the free space of the old one so that I can copy across the entire micro sd card?

Hi Ertosp,

as long as you still have working RPi or some other Linux PC, mounting the image file and then using GParted might be the way to go. See for example:

Shrinking images on Linux

There are dozens of tutorials on the web, most follow the path of mounting the image on a loop back device, adjusting the partition size and then cutting the file. Personally I’d think the risk of ruining your whole image by improper cutting is way too high, so I’d be tempted to simply make a new image of the shrinked partition.

Thanks @fretzke. I will give it a try later today or tomorrow. I was thinking that I should probably do a fresh install, but at the same time I’ve got so much stuff installed, it would take hours…

Thanks anyway, will let you know how that goes.

I´ve decided to re-install everything from scratch… It will take some time but hopefully will end up with a more stable version.

In my dreams, I would set few options in osmc addon like: when to backup (let’s say every 1st of the month at 03:00), where to backup (external usb drive/folder), delete older than (delete backups older than let’s say 6 months).

So, every 1st of the month at 03:00 osmc would boot into kind of recovery mode, mount sd card and external usb drive, and then create an image of the sd card.

When everything is finished, osmc would reboot.

Sweet dreams, aren’t they?

for a manual but still convenient solution on OSX i can recommend this: https://www.tweaking4all.com/software/macosx-software/macosx-apple-pi-baker/

cheers, bendsch

1 Like

It’s on my todo list for a bash script for that. I’m sure my SD card will fail before I get around to it.:wink:

BTW: why the re-boot?

Could somebody give me advice? More exactly I need an example of command for MySql databases backup which I use with OSMC.
Now I use
mysqldump -u root -p MyVideos107 > MyVideos107_$(date +%F).sql
or
mysqldump -u kodi -p MyVideos107 > MyVideos107_$(date +%F).sql
Does it enough?

Do you want to copy the data or do you want a backup that reproduces table structures etc, without copying the actual data files?

I would like to have a better way to restore MySQL databases if they fail.
I think I want to copy the data and structure.

If you want to copy data as well, you will have point-in-time consistency issues if Kodi is still running. I would therefore recommend that you stop Kodi, using sudo systemctl stop mediacenter, and then run a backup of the whole of the /home/osmc/.kodi directory and all its subdirectories. That way you get all add-ons etc. backed up as well and you know that everything is consistent. Then run sudo systemctl start mediacenter to restart Kodi.

I’m sorry. Unfortunately I explained poorly what I need. I know how I may make my Kodi backup. I asked how I may make a backup of MySQL bases that run on my home server.

I don’t claim to have a great knowledge of MySQL but AFAIK you have to possible strategies:

  • stop the database and make physical copies of the files; or

  • use the mysqldump command to make a logical copy.

The first option will be faster and give smaller backup size and, unless you need a 24x7 system, is the one I’d choose.

I understand it. I would like to get advices about precise command line options for use mysqldump in the context of OSMC.