checkBackup
This commit is contained in:
Executable
+49
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from pathlib import Path
|
||||
from datetime import date, timedelta
|
||||
|
||||
BACKUP_ROOT = Path("/BACKUP")
|
||||
STALE_DAYS = 2
|
||||
|
||||
cutoff = (date.today() - timedelta(days=STALE_DAYS)).strftime("%Y%m%d")
|
||||
|
||||
for directory in sorted(BACKUP_ROOT.iterdir()):
|
||||
if not directory.is_dir():
|
||||
continue
|
||||
|
||||
if directory.name == "default":
|
||||
continue
|
||||
|
||||
latest_file = None
|
||||
latest_date = "00000000"
|
||||
|
||||
for zip_file in directory.rglob("*.zip"):
|
||||
name = zip_file.name
|
||||
|
||||
# expected format: YYYYMMDD_HHMM.zip
|
||||
try:
|
||||
date_part = name.split("_")[0]
|
||||
|
||||
if len(date_part) != 8 or not date_part.isdigit():
|
||||
continue
|
||||
|
||||
except Exception:
|
||||
continue
|
||||
|
||||
if date_part > latest_date:
|
||||
latest_date = date_part
|
||||
latest_file = zip_file
|
||||
|
||||
if latest_file is None:
|
||||
print(f"{directory.name} -> NO BACKUPS")
|
||||
continue
|
||||
|
||||
status = "STALE" if latest_date < cutoff else "OK"
|
||||
|
||||
print(
|
||||
f"{directory.name} -> "
|
||||
f"{latest_file.name} -> "
|
||||
f"{latest_date} -> "
|
||||
f"{status}"
|
||||
)
|
||||
@@ -17,7 +17,7 @@ services:
|
||||
ipv4_address: 10.5.0.200
|
||||
|
||||
traefik:
|
||||
image: docker.io/library/traefik:3.1
|
||||
image: docker.io/library/traefik:3.6
|
||||
container_name: traefik
|
||||
ports:
|
||||
- 80:80
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user