I am currently struggeling to switch the daily backup to a weekly backup.
I found in /etc/cron-daily four scripts(?):
apache2
apt-compat
dietpi
dpkg
I a not undestand if theses are the scripts and how can I modifiy them to run my backup on a weekly base, restoring three versions, instead on a daily base, as the dietpi menue offers.
You could use the similar part of the dietpi script in /etc/cron-daily in /etc/weekly.
Generate a file dietpi in /etc/weekly like this:
#!/bin/bash
{
#////////////////////////////////////
# DietPi Cron.Weekly script
#
#////////////////////////////////////
#
# Info:
# - Location: /etc/cron.weekly/dietpi
#
#////////////////////////////////////
# Assure that whiptail dialogues are skipped, even when the script is called manually, since STDOUT is redirected
export G_INTERACTIVE=0
#----------------------------------------------------------------
# DietPi-Backup weekly
/boot/dietpi/dietpi-backup 1
#----------------------------------------------------------------
}
I am not sure whether the line export G_INTERACTIVE is needed. @MichaIng: Can you clearify this?
The script above does not interpret the DAILY_BACKUP option of dietpi-backup.
Use dietpi-cron to set the instant of time the backup shall take place.
If you would change the script dietpi-backup, e.g. to add an option WEEKLY_BACKUP, this would be overwritten in case of DietPi updates.
This would be an extension of dietpi-backup to add such an option and suppress the daily backup at the day of the weekly backup. Additionally, a different location for the weekly backup with a different Amount option would be needed.
Jep that would work. export G_INTERACTIVE=0 is not needed, as cron runs without STDIN, in which case DietPi scripts internally set G_INTERACTIVE=0 automatically. But it does not hurt either. That way you can run the script also manually from console, so see whether/how it works, and it won’t show interactive prompts and such.
Yeah, we thought about some more flexible options, like setting an amount of daily + weekly backup iterations, allowing to set e.g. “0” daily but “2” weekly as well. But the logic needed if we want to keep doing incremental backups from older iterations, is actually not that trivial .
You are going to need to make your daily script executable. From the same directory this command should do that:
chmod +x dietpi
After that again from the same directory you can probably simply type:
.\dietpi
into the console to run it, but you might want to check with others first on the forum to make sure I am correct as I have not used dietpi’s backup scripts before.