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:
@@ -16,6 +16,7 @@ import requests
|
|||||||
import fnmatch
|
import fnmatch
|
||||||
import yaml
|
import yaml
|
||||||
import paramiko
|
import paramiko
|
||||||
|
import shutil
|
||||||
#import numpy as np
|
#import numpy as np
|
||||||
|
|
||||||
file_path = os.path.realpath(__file__)
|
file_path = os.path.realpath(__file__)
|
||||||
@@ -616,10 +617,36 @@ if _BACKUP:
|
|||||||
# input("????")
|
# input("????")
|
||||||
#cmnd = "find {} -maxdepth 1 -type d -mtime +30 -exec rm -rf {{}} \;".format(BACKUP_DIR)
|
#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}"
|
||||||
|
|
||||||
|
|
||||||
#print(cmnd)
|
#print(cmnd)
|
||||||
# input("????")
|
# input("????")
|
||||||
if _EXECUTE:
|
if _EXECUTE:
|
||||||
status, output = subprocess.getstatusoutput(cmnd)
|
status, output = subprocess.getstatusoutput(cmnd)
|
||||||
|
for f in output.splitlines():
|
||||||
|
pattern = r"^[0-9]{4}.*" # regex pattern: string starts with 'abc'
|
||||||
|
|
||||||
|
if re.match(pattern, f):
|
||||||
|
print("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
|
||||||
|
print(epoch_time) # Output: 45
|
||||||
|
if x > "2592000":
|
||||||
|
dir_path = "{BACKUP_ROOT}/{f}"
|
||||||
|
print(f"removing {dir_path}")
|
||||||
|
#shutil.rmtree(dir_path)
|
||||||
|
|
||||||
|
|
||||||
|
else:
|
||||||
|
print("No match.")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
now = datetime.datetime.now()
|
now = datetime.datetime.now()
|
||||||
ENDTIME = now.strftime("%Y-%m-%d_%H:%M:%S")
|
ENDTIME = now.strftime("%Y-%m-%d_%H:%M:%S")
|
||||||
#msg = {"status":"finished","bak_name":b,"start_time":DATETIME,"end_time":ENDTIME,"progress":0}
|
#msg = {"status":"finished","bak_name":b,"start_time":DATETIME,"end_time":ENDTIME,"progress":0}
|
||||||
|
Reference in New Issue
Block a user