Page 2 of 2

Re: Backup script in cron.daily

Posted: Fri Oct 30, 2020 4:19 pm
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 ;).

Re: Backup script in cron.daily

Posted: Fri Oct 30, 2020 9:26 pm
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)?

Re: Backup script in cron.daily

Posted: Fri Oct 30, 2020 11:41 pm
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

Re: Backup script in cron.daily

Posted: Sat Oct 31, 2020 9:44 pm
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?

Re: Backup script in cron.daily

Posted: Sat Oct 31, 2020 10:22 pm
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

Re: Backup script in cron.daily

Posted: Sun Nov 01, 2020 6:45 pm
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 :).