Backup - Is there a right way to clone or backup the entire DietPi

Hello everyone,

I am currently looking up for a way to Completely Backup or clone the entire DietPi Installation, including post install modifications like applications into am image to be later reimage in the event of system corruption.

We have been experiencing power outage for the last few days, and it keeps on corrupting my DietPi installation. It won’t boot or will boot incompletely. I have tested these with random results after outage:

  • Ping
  • VNC (Local)
  • SSH (At times it works and it takes time or not at all)
  • Local SMB (At times it shows shares or not at all)

I have a solution that works but after an outage it wont boot properly again, so I need to redo it. Its clonezilla.

What I experience previously as a clean install, after an outage it does work fine. But if it comes from a restore from clonezilla, during outage it wont boot properly anymore.

If you guys have a better backup solution at times for outage and corruption. Please let me know. UPS is an option that I can do, but my concern is a regular monthly System Snapshot would be a good safety measure.

I am using dd for this purpose, so something like this:

dd if=/dev/mmcblk0 of=$HOSTNAME.$(date +%Y-%m-%d).img bs=1M

if you want you can compress it afterwards with:
gzip -f $HOSTNAME.$(date +%Y-%m-%d).img

The image can then be flashed to a SD card if needed.

Pausentee

Hi, thanks for the reply. I am currently searching online using DD. If I understand it correctly you will be running it within DietPi and are doing a backup while the OS is currently running?

I’m a bit confused. Will it affect my operation while its doing it. I am using a RPi B+ by the way, and older model.

If you really like to create/clone an image, you could use our dietpi-imager tool.

bash -c "$(curl -sSfL 'https://raw.githubusercontent.com/MichaIng/DietPi/master/.meta/dietpi-imager')"

But this would require to be executed on another Linux box. Because it is not really possible to create a consistent backup on a running system.

Another option would be to create a dietpi-backup on a separate USB pen stick and not on the same SD card. This way you would be able to restore the backup right away on a new installation during initial boot. You just would need to activate the feature on dietpi.txt on a new flashed image before first boot.

As well you could try to boot directly from USB pen stick instead of SD card. Maybe it will be more reliable compare to SD card. And of course use a UPS could help, if you have so many power outages.

I am doing it this way yes and I never had a problem to restore from that image. But as Joulinar said, it is better and 100% only if you take your SD card to another computer and do it from there.

But you can just try it out. Just dd an image from your running system and flash it on some sd card and look how it works.

To reduce impact and inconsistencies, you could stop all DietPi managed services before

dietpi-services stop

Hello again,

I have reinstalled DietPi yet again. For me to do this successfully, can I do it on a different Linux Distro? I am okay taking the SD card for backup, I just don’t know how to do it on another machine.

What about using dietpi-backup?
See System Maintenance - DietPi.com Docs
and
DietPi-Backup in an multi-device environment - DietPi blog

1 Like

Thanks for suggesting StephanStS.

I just discovered it earlier using the dietpi-launcher command. What I was looking for was the exact backup that I need. It’s similar to Rsync, that I am quite familiar with and I’m glad it came built-in to dietpi.

I am using it like in my blog post, but with much more DietPi instances. Works well and saved my a** a couple of times.

1 Like

To create an .img file, you can “poweroff” your DietPi system and run the following command from another Linux host/external system:

bash -c "$(curl -sSf https://raw.githubusercontent.com/MichaIng/DietPi/master/.build/images/dietpi-imager)"