Skip to content

Commit bb4aea5

Browse files
author
juancarlos.cavero
committed
Fix backup spam: skip if last backup was less than 12h ago
1 parent a4144cc commit bb4aea5

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

platform-api/monitor.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,18 @@ def _maintenance_loop():
113113
time.sleep(300) # Wait 5 min after startup
114114
while True:
115115
try:
116-
_backup()
116+
# Only backup if last one was >12h ago
117+
import glob
118+
existing = sorted(glob.glob(os.path.join(BACKUP_DIR, "pleng-*.tar.gz")))
119+
if existing:
120+
last_mod = os.path.getmtime(existing[-1])
121+
hours_since = (time.time() - last_mod) / 3600
122+
if hours_since < 12:
123+
logger.info(f"Skipping backup — last one was {hours_since:.1f}h ago")
124+
else:
125+
_backup()
126+
else:
127+
_backup()
117128
except Exception as e:
118129
logger.error(f"Backup error: {e}")
119130
try:

0 commit comments

Comments
 (0)