fix(backup-freshness-check): compare timezone-aware UTC datetimes

utcfromtimestamp is deprecated and its warning ended up in the check
output; it also compared a UTC snapshot time with local now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RywMtsL8qXG7GDY3MHq9Uh
This commit is contained in:
CroneKorkN 2026-10-23 15:21:51 +02:00
parent 0684323cf3
commit 4cfc751902
No known key found for this signature in database

View file

@ -2,10 +2,10 @@
import json import json
from subprocess import check_output from subprocess import check_output
from datetime import datetime, timedelta from datetime import datetime, timedelta, timezone
now = datetime.now() now = datetime.now(timezone.utc)
two_days_ago = now - timedelta(days=2) two_days_ago = now - timedelta(days=2)
with open('/etc/backup-freshness-check.json', 'r') as file: with open('/etc/backup-freshness-check.json', 'r') as file:
@ -30,8 +30,9 @@ for dataset in config['datasets']:
continue continue
newest_backup_snapshot = snapshots[-1] newest_backup_snapshot = snapshots[-1]
snapshot_datetime = datetime.utcfromtimestamp( snapshot_datetime = datetime.fromtimestamp(
int(check_output(['zfs', 'list', '-p', '-H', '-o', 'creation', '-t', 'snapshot', newest_backup_snapshot]).decode()) int(check_output(['zfs', 'list', '-p', '-H', '-o', 'creation', '-t', 'snapshot', newest_backup_snapshot]).decode()),
timezone.utc,
) )
if snapshot_datetime < two_days_ago: if snapshot_datetime < two_days_ago: