MichaIng / DietPi

Lightweight justice for your single-board computer!
https://dietpi.com/
GNU General Public License v2.0
4.84k stars 495 forks source link

Permit weekly backups in dietpi-backup #6869

Open beesyrupfactory opened 8 months ago

beesyrupfactory commented 8 months ago

Creating a feature request

Is your feature request related to a problem? Please describe:

Describe the solution you'd like:

Describe alternatives you've considered:

Additional context

Joulinar commented 8 months ago

Theoretically you could exclude services from being stopped by DietPi Backup.

beesyrupfactory commented 8 months ago

@Joulinar thanks for your response. Is there any documentation on this procedure? If this is the appropriate way to move forward, I would like to employ it rather than stopping daily backups.

Joulinar commented 8 months ago

dietpi-services > select the service in question > adjust Include/Exclude to Exclude > done

MichaIng commented 8 months ago

Hmm, I thought there was a request about this already, but probably we only internally talked about this. What we actually thought about is adding a way to not only allow to keep X daily backups, but also X weekly backups. When allowing to choose "0" for the daily backups to keep, then it would be essentially only weekly backups 🤔.

I already have an idea how to implement it, but have more high priority tasks to do. However, essentially my idea was to use the same daily cron job and rotation as well for the weekly backups: https://github.com/MichaIng/DietPi/blob/dev/dietpi/dietpi-backup#L136-L154 The suffixes for the backup directories remain indicating the day/number of a backup, so for weekly backups there will be e.g. data_7, data_14, data_21, with none in between (unless >7 daily backups), rotated/increased every day/with every backup created. E.g. if you choose to keep 7 daily and 4 weekly backups, it will do a backup every and:

Note that the rotation loop is inverse, i.e. it starts with the oldest backup to rotate.

If 0 daily backups are chosen, and we want to support this, then it would need to skip creating a new backup if there is one already between data_2 (after rotation) and data_7.

Using an otherwise removed backup as basis for the new one could be done like this:

It is not so trivial to implement, but overall cleaner than having two cron jobs where we'd need to take care that they do not overlap/conflict or doubled backups, like a daily and a weekly at the same time.

tonystower commented 2 months ago

Thanks Michael - I think your suggestion would work really well and I would love to see daily/weekly/monthly options available as you suggest.

beesyrupfactory commented 2 months ago

dietpi-services > select the service in question > adjust Include/Exclude to Exclude > done

@Joulinar - Thank you! This is exactly what I want. I'm happy to have daily backups, but I want to make sure that some of the services I want to keep alive 100% of the time were excluded. This addresses this perfectly.