Backup script in cron.daily

Having issues with your DietPi installation, or, found a bug? Post it here.
User avatar
MichaIng
Site Admin
Posts: 2422
Joined: Sat Nov 18, 2017 6:21 pm

Re: Backup script in cron.daily

Post by MichaIng »

You can add services to the dietpi-services control via its GUI.

Btw in your rotate script, move your last directory (4) to the initial place instead of removing it. This will reduce the execution time and writes as only changes are synced while identical files are left unchanged ;).
Lycidias
Posts: 7
Joined: Mon Oct 26, 2020 11:01 am

Re: Backup script in cron.daily

Post by Lycidias »

Great idea, thanks :)

Code: Select all

#!/bin/bash
#
mv /mnt/hdd1/backup/dietpi-backup_4 "/mnt/hdd1/backup/dietpi-backup"
mv /mnt/hdd1/backup/dietpi-backup_3 "/mnt/hdd1/backup/dietpi-backup_4"
mv /mnt/hdd1/backup/dietpi-backup_2 "/mnt/hdd1/backup/dietpi-backup_3"
cp /mnt/hdd1/backup/dietpi-backup "/mnt/hdd1/backup/dietpi-backup_2"
/boot/dietpi/dietpi-backup 1
Do you mean Like this:
Move (4) to Initial and copy Initial to (2)?
User avatar
Joulinar
Posts: 2572
Joined: Sat Nov 16, 2019 12:49 am

Re: Backup script in cron.daily

Post by Joulinar »

should be more like this

Code: Select all

mv /mnt/hdd1/backup/dietpi-backup_3 "/mnt/hdd1/backup/dietpi-backup_4"
mv /mnt/hdd1/backup/dietpi-backup_2 "/mnt/hdd1/backup/dietpi-backup_3"
mv /mnt/hdd1/backup/dietpi-backup "/mnt/hdd1/backup/dietpi-backup_2"
mv /mnt/hdd1/backup/dietpi-backup_4 "/mnt/hdd1/backup/dietpi-backup"
/boot/dietpi/dietpi-backup 1
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
Lycidias
Posts: 7
Joined: Mon Oct 26, 2020 11:01 am

Re: Backup script in cron.daily

Post by Lycidias »

Thank you very much :-)

My external hdd1 is formatted in ext4. How can i copy the files to a ntfs formatted Computer or hdd? I tried it but there were symlink/permission errors or to many files to copy or the Filesystem does Not Support something.

Another question: on raspbian it was possible to backup my whole sd card to an Image. Is this also possible on dietpi?
User avatar
Joulinar
Posts: 2572
Joined: Sat Nov 16, 2019 12:49 am

Re: Backup script in cron.daily

Post by Joulinar »

I would recommend to use ext4 as target device to keep thinks like permissions and sym links.

To creaqte an image, you can use dietpi-imager: For this you would need to plug your SD card into another system

https://github.com/MichaIng/DietPi/issu ... -554477828
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
User avatar
MichaIng
Site Admin
Posts: 2422
Joined: Sat Nov 18, 2017 6:21 pm

Re: Backup script in cron.daily

Post by MichaIng »

Jep dietpi-imager is an idea, although its purpose is to create a fresh DietPi image and for this it minimises the file system and partition size.

Was this possible on Raspbian from the running system itself? I mean in theory /dev/mmcblk0 can be read to an image file via dd, but I would never assume that there will be a reliable result as long as any of the file systems is still writable. And remounting the root file system read-only is not reliably possible as there are usually still parts write-opened by some system process, as Joulinar might remember, the failing and hard to investigate mount -o remount,ro / :(. So if there is any tool on Raspbian that manages this, I would be happy to check out the method and implement something similar into dietpi-backup :).
Post Reply