0

I have been backing up my Raspberry Pi using a script that:

  1. Stops the cron service

  2. does a "dd if=/dev/mmcblk0 of=sharedStorageFile.img

  3. starts the cron service

Every time I have had to use sharedStorageFile.img for a restore onto a SDCard I was able to bring the Raspberry Pi back up at the point of the backup.

I was wondering if anyone thought I really needed to stop the cron service (it takes anywhere from 30 minutes to 11 hours to perform the backup) of course unless one of the cron jobs would affect the backups (which I can't think of one).

Also anyone have a better way of getting an image of the SDCard being used at a regular interval?

Thank you for any assistance

2

It's pure luck this works at all. You had to remount all filesystems on the SD card read-only before you can take an image this way. If you don't do that, you may accidentally image two or more states with intermediate changes on the way, which will give you data corruption.

A better solution is using a filesystem that natively supports snapshots, e.g. btrfs. If you wanted to snapshot whole filesystems instead of files, you want to take at look at the device-mapper snapshot feature and the logical volume manager.

1

Search for ``rpi-clone''. I believe the latest version is 1.7. Using an SD carrier/w chip in a USB-SD adapter one can back up the entire file system while it is mounted and active.

  • That one is a wrapper for rsync. But it does the job, so +1. – Janka Feb 16 '18 at 23:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.