[enhancement] Smart delete modifications

Bug #406765 reported by Bart de Koning
22
This bug affects 6 people
Affects Status Importance Assigned to Milestone
Back In Time
Fix Released
High
Unassigned

Bug Description

Smart delete now only keeps all the snapshots for today and yesterday, and one for last week and the week before. I think the gap between yesterday and one week ago is quite big. What if a file got corrupted two days ago (Tuesday), but was created on Monday. It should keep one or two snapshots for the other days of the current week.
Manual settings for smart delete would be ideal of course, however might be a bit difficult to implement.

description: updated
summary: - Smart delete should keep also one snapshot per day for this week
+ [enhancement] Smart delete should keep also one snapshot per day for
+ this week
Revision history for this message
Bart de Koning (bratdaking) wrote : Re: [enhancement] Smart delete should keep also one snapshot per day for this week

Having manual settings was to much of a hassle right now :-), but if anybody likes to keep additional snapshots for the rest of the week, copy and paste the following lines of code into

/usr/share/backintime/common/snapshots.py

at line 783 (that is in the smart_remove def between the code to keep today and yesterday, and last week), mind the spacing!
***

  #one per day for the rest of this week
  if now.weekday() > 1:
   for weekday in xrange( 1, now.weekday() ):
    #print "weekday: %s" % weekday
    max_date = now - datetime.timedelta( days = weekday + 1 )
    min_date = max_date
    keep_snapshots = self._smart_remove_keep_first_( snapshots, keep_snapshots, min_date, max_date )

***
For the convenience I included my whole snapshots.py

I am not sure whether more people would like this behaviour, so I did not include this into a new development branch or something, neither did I polish the settings dialog.

Cheers

Changed in backintime:
status: New → Fix Committed
Changed in backintime:
importance: Undecided → Wishlist
summary: - [enhancement] Smart delete should keep also one snapshot per day for
- this week
+ [enhancement] Smart delete modifications
Changed in backintime:
status: Fix Committed → In Progress
Revision history for this message
Cyberdude (gabor-sunseaker) wrote :

I'd like to see this enhancement make it into the next release of BiT. For now I've just modified the snapshots.py as mentioned above.

To keep things neat I also fixed the settings dialogue to show the new option by editing file settingsdialog.py. The change I made was adding

\n- keep one snapshot per day for the rest of this week

to the following line of code

label = QLabel( QString.fromUtf8( _( '- keep all snapshots from today and yesterday\n- keep one snapshot per day for the rest of this week\n- keep one snapshot for the last week and one for two weeks ago\n- keep one snapshot per month for all previous months of this year and all months of the last year \n- keep one snapshot per year for all other years' ) ),self )

I don't know how to make the change for other languages though.

Dan (danleweb)
Changed in backintime:
importance: Wishlist → Medium
Revision history for this message
Dan (danleweb) wrote :

The roules can be changed to:
1. keep all snapshots for today an yesterday
2. keep one snapshot per day for the rest or this week and last week
3. keep one snapshot per week for 2 & 3 weeks ago
4. keep one snapshot per month for all the month of this and last year
5. keep one snapshot per year for all years

Revision history for this message
David (dcummins) wrote :

Dan,

Those rules would be an improvement from my perspective, but I'd be concerned about someone with a tighter space requirement on their backup volume. For example, every December, you'd have to have room for 24 monthly's, and when January comes that drops back to 12.

Would it be possible to change the algorithm to count days, weeks, and months, instead of just looking at a calendar? This strategy would also move closer to allowing custom schedules (which is what I really want) because you'd only have to process 3 variables:

1. keep all snapshots from today and yesterday.
2. keep 1 snapshot per day for the previous [40] days.
3. keep 1 snapshot per week for the previous [6] weeks.
4. keep 1 snapshot per month for the previous [14] months.
5. keep 1 snapshot per year for all previous years.

(those are the settings I would use; your own defaults might look different)

Everybody's needs will vary slightly, depending on how frequently they take snapshots in the first place, and how much capacity they have for archives, and what kind of data is being backed up, etc.

But by using a count instead of a calendar, you could at least keep track of your available storage space, and if it is filling up too quickly you could check if your delete schedule is not aggressive enough - not that you need to try to hold on until January.

Thanks for considering.

Revision history for this message
Dan (danleweb) wrote :

Very good idea.

Plus it can be configurable:
- keep all snapshots for that last [N1] days
- keep 1 snapshot per day for the previous [N2] days
- keep 1 snapshot per week for the previous [N3] weeks
- keep 1 snapshot per month for the previous [N4] months
- keep 1 snapshot per year for the previous [N5] years

With N = -1 for all.

Regards,
Dan

Changed in backintime:
importance: Medium → High
Revision history for this message
David (dcummins) wrote :

Dan,

I installed 1.0.6 and enabled this feature. The interface looks wonderful, thanks for putting this in.

It looks like, at every level, you have the count starting from today. I can work with that. But I'm going to watch it for the next couple of days, because I now only have 2 snapshots under "Last week" where there should be one per day - and unfortunately I don't have proof that they were there before, but I don't see any reason for the gaps...

Revision history for this message
David (dcummins) wrote :

The new smart delete rules have been working perfectly for me. So, I also upgraded to 1.0.6 on another computer, set up the rules, and paid careful attention to the before / after. No problems.

The missing snapshots on my first attempt must have never been there in the first place - which is plausible because it was over the holidays and the computer wasn't in active use.

I'm very happy. Thank you, Dan!

 - David

Dan (danleweb)
Changed in backintime:
status: In Progress → Fix Committed
Dan (danleweb)
Changed in backintime:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.