mirror of
https://gitlab.sectorq.eu/jaydee/omv_backup.git
synced 2025-09-13 12:10:12 +02:00
build
This commit is contained in:
@@ -616,7 +616,7 @@ if _BACKUP:
|
||||
logging.info("Removing old dirs")
|
||||
# input("????")
|
||||
#cmnd = "find {} -maxdepth 1 -type d -mtime +30 -exec rm -rf {{}} \;".format(BACKUP_DIR)
|
||||
cmnd = f"cd {BACKUP_ROOT} find ./ -maxdepth 1 -type d -mmin +30 -exec rm -rf {{}} \\;"
|
||||
#cmnd = f"cd {BACKUP_ROOT} find ./ -maxdepth 1 -type d -mmin +30 -exec rm -rf {{}} \\;"
|
||||
|
||||
cmnd = "ls {BACKUP_ROOT}"
|
||||
|
||||
@@ -627,7 +627,7 @@ if _BACKUP:
|
||||
status, output = subprocess.getstatusoutput(cmnd)
|
||||
for f in output.splitlines():
|
||||
pattern = r"^[0-9]{4}.*" # regex pattern: string starts with 'abc'
|
||||
|
||||
logging.info(f"Checking {f}")
|
||||
if re.match(pattern, f):
|
||||
logging.info("Match!")
|
||||
dt = datetime.datetime.strptime(f, "%Y-%m-%d_%H-%M-%S")
|
||||
@@ -638,10 +638,21 @@ if _BACKUP:
|
||||
if x > "2592000":
|
||||
dir_path = "{BACKUP_ROOT}/{f}"
|
||||
logging.info(f"removing {dir_path}")
|
||||
#shutil.rmtree(dir_path)
|
||||
shutil.rmtree(dir_path)
|
||||
else:
|
||||
print("No match.")
|
||||
|
||||
|
||||
cmnd = "ls {BACKUP_ROOT}|grep _running"
|
||||
#print(cmnd)
|
||||
# input("????")
|
||||
logging.info(f"removing obsolete dirs")
|
||||
if _EXECUTE:
|
||||
status, output = subprocess.getstatusoutput(cmnd)
|
||||
for f in output.splitlines():
|
||||
dir_path = "{BACKUP_ROOT}/{f}"
|
||||
logging.info(f"removing {dir_path}")
|
||||
shutil.rmtree(dir_path)
|
||||
|
||||
now = datetime.datetime.now()
|
||||
ENDTIME = now.strftime("%Y-%m-%d_%H:%M:%S")
|
||||
#msg = {"status":"finished","bak_name":b,"start_time":DATETIME,"end_time":ENDTIME,"progress":0}
|
||||
|
Reference in New Issue
Block a user