Compare commits

...

6 Commits

Author SHA1 Message Date
298c9aee23 build 2025-09-02 22:52:54 +02:00
808f92c4d1 build 2025-09-02 22:50:36 +02:00
43f6d2abcb build 2025-09-02 22:47:01 +02:00
81c7ead7b2 build 2025-09-02 22:44:12 +02:00
cd818da774 build 2025-09-02 22:26:51 +02:00
a1dfbd664c build 2025-09-02 22:23:40 +02:00

View File

@@ -600,7 +600,7 @@ def backup_job(pl):
#logging.info(cmnd)
logging.info("Removing latest link")
# input("????")
if _EXECUTE:
if not _DRYRUN:
status, output = subprocess.getstatusoutput(cmnd)
if _FIRST:
cmnd = f"cd {BACKUP_ROOT}; ln -s initial latest"
@@ -636,6 +636,50 @@ def backup_job(pl):
shutil.rmtree(dir_path)
else:
print("No match.")
if not _DRYRUN:
logging.info(f"Clearing multiple days")
multiple_per_day = {}
to_remove = []
for f in output.splitlines():
pattern = r"^[0-9]{4}-[0-9]{2}-[0-9]{2}_[0-9]{2}-[0-9]{2}-[0-9]{2}$" # regex pattern: string starts with 'abc'
if re.match(pattern, f):
cday = f.split("_")[0]
if cday in multiple_per_day:
multiple_per_day[cday].append(f)
else:
multiple_per_day[cday] = [f]
# # logging.info("Match!")
# dt = datetime.datetime.strptime(f, "%Y-%m-%d_%H-%M-%S")
# epoch_time = int(dt.timestamp())
# now_epoch = int(datetime.datetime.now().timestamp())
# x = now_epoch - epoch_time
# # logging.info(epoch_time) # Output: 45
# if x > 2592000:
# dir_path = f"{BACKUP_ROOT}/{f}"
# logging.info(f"removing {dir_path}")
# shutil.rmtree(dir_path)
else:
print("No match.")
logging.info(f"Clearing multiple days: {multiple_per_day}")
for f in multiple_per_day:
logging.info(f"Looping multiple_per_day : {f}")
if len(multiple_per_day[f]) > 1:
last = multiple_per_day[f][-1]
multiple_per_day[f].pop()
logging.info(f"Last from day: {last}")
for d in multiple_per_day[f]:
logging.info(f"Looping multiple_per_day : {f} : {d}")
dir_path = f"{BACKUP_ROOT}/{d}"
logging.info(f"removing {dir_path}")
shutil.rmtree(dir_path)
cmnd = f"ls {BACKUP_ROOT}|grep _running"
logging.info(f"removing obsolete dirs")