diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ec9361..7d0aa43 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ System: Control panel: * The new check that system services are running mistakenly checked that the Dovecot Managesieve service is publicly accessible. Although the service binds to the public network interface we don't open the port in ufw. On some machines it seems that ufw blocks the connection from the status checks (which seems correct) and on some machines (mine) it doesn't, which is why I didn't notice the problem. +* The current backup chain will now try to predict how many days until it is deleted (always at least 3 days after the next full backup). v0.07 (February 28, 2015) ------------------------- diff --git a/management/backup.py b/management/backup.py index d161719..fdcc524 100755 --- a/management/backup.py +++ b/management/backup.py @@ -67,9 +67,29 @@ def backup_status(env): # This is relied on by should_force_full() and the next step. backups = sorted(backups.values(), key = lambda b : b["date"], reverse=True) + # Get the average size of incremental backups and the size of the + # most recent full backup. + incremental_count = 0 + incremental_size = 0 + first_full_size = None + for bak in backups: + if bak["full"]: + first_full_size = bak["size"] + break + incremental_count += 1 + incremental_size += bak["size"] + + # Predict how many more increments until the next full backup, + # and add to that the time we hold onto backups, to predict + # how long the most recent full backup+increments will be held + # onto. Round up since the backup occurs on the night following + # when the threshold is met. + deleted_in = None + if incremental_count > 0 and first_full_size is not None: + deleted_in = "approx. %d days" % round(keep_backups_for_days + (.5 * first_full_size - incremental_size) / (incremental_size/incremental_count) + .5) + # When will a backup be deleted? saw_full = False - deleted_in = None days_ago = now - datetime.timedelta(days=keep_backups_for_days) for bak in backups: if deleted_in: diff --git a/management/templates/system-backup.html b/management/templates/system-backup.html index 1a166c1..7ff1a86 100644 --- a/management/templates/system-backup.html +++ b/management/templates/system-backup.html @@ -15,7 +15,7 @@
The backup directory currently contains the backups listed below. The total size on disk of the backups is .
+The backup directory currently contains the backups listed below. The total size on disk of the backups is currently .
').text(b.deleted_in) ); else - tr.append( $(' | n/a | ') ); + tr.append( $('unknown | ') ); $('#backup-status tbody').append(tr); total_disk_size += b.size;