mirror of
https://gitlab.sectorq.eu/jaydee/omv_backup.git
synced 2025-09-13 20:20:11 +02:00
build
This commit is contained in:
@@ -479,9 +479,9 @@ def restore_job(_APP):
|
|||||||
status, output = subprocess.getstatusoutput(cmnd)
|
status, output = subprocess.getstatusoutput(cmnd)
|
||||||
|
|
||||||
def backup_job(server):
|
def backup_job(server):
|
||||||
client = mqtt.Client()
|
client2 = mqtt.Client()
|
||||||
client.username_pw_set("jaydee", "jaydee1")
|
client2.username_pw_set("jaydee", "jaydee1")
|
||||||
client.connect("mqtt.home.lan",1883,60)
|
client2.connect("mqtt.home.lan",1883,60)
|
||||||
logging.info(f'starting backup job')
|
logging.info(f'starting backup job')
|
||||||
|
|
||||||
finished = []
|
finished = []
|
||||||
@@ -490,11 +490,11 @@ def backup_job(server):
|
|||||||
topic = "sectorq/amd/restore"
|
topic = "sectorq/amd/restore"
|
||||||
msg = {"mode":"restore", "status":"restore","bak_name":"s","host":0,"cur_job":"aaa","start_time":1,"end_time":1,"progress":0,"finished":0,"used_space":0}
|
msg = {"mode":"restore", "status":"restore","bak_name":"s","host":0,"cur_job":"aaa","start_time":1,"end_time":1,"progress":0,"finished":0,"used_space":0}
|
||||||
|
|
||||||
client.publish(topic, json.dumps(msg),qos=0, retain=True)
|
client2.publish(topic, json.dumps(msg),qos=0, retain=True)
|
||||||
#client.publish(topic, msg)
|
#client2.publish(topic, msg)
|
||||||
topic = "sectorq/amd/backups"
|
topic = "sectorq/amd/backups"
|
||||||
msg = {"mode":_MODE, "status":"started","bak_name":"complete","host":"","cur_job":"","start_time":STARTTIME,"end_time":"in progress","progress":0,"finished":",".join(finished)}
|
msg = {"mode":_MODE, "status":"started","bak_name":"complete","host":"","cur_job":"","start_time":STARTTIME,"end_time":"in progress","progress":0,"finished":",".join(finished)}
|
||||||
client.publish(topic, json.dumps(msg),qos=0, retain=True)
|
client2.publish(topic, json.dumps(msg),qos=0, retain=True)
|
||||||
|
|
||||||
# iterate over files in
|
# iterate over files in
|
||||||
# that directory
|
# that directory
|
||||||
@@ -507,7 +507,7 @@ def backup_job(server):
|
|||||||
if not backups[host]["jobs"][b]["active"]:
|
if not backups[host]["jobs"][b]["active"]:
|
||||||
logging.info("Backup {} is not active!".format(b))
|
logging.info("Backup {} is not active!".format(b))
|
||||||
msg = {"status":"inactive","bak_name":b,"start_time":"inactive","end_time":"inactive","progress":0}
|
msg = {"status":"inactive","bak_name":b,"start_time":"inactive","end_time":"inactive","progress":0}
|
||||||
client.publish(topic, json.dumps(msg),qos=0, retain=True)
|
client2.publish(topic, json.dumps(msg),qos=0, retain=True)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
SOURCE_DIR = backups[host]["jobs"][b]["source"]
|
SOURCE_DIR = backups[host]["jobs"][b]["source"]
|
||||||
@@ -528,7 +528,7 @@ def backup_job(server):
|
|||||||
# msg = {"status":"started","bak_name":b,"start_time":DATETIME,"end_time":"in progress", "progress":0}
|
# msg = {"status":"started","bak_name":b,"start_time":DATETIME,"end_time":"in progress", "progress":0}
|
||||||
msg = {"mode":_MODE, "status":"started","bak_name":"complete","host":host,"cur_job":b,"start_time":STARTTIME,"end_time":"in progress","progress":0,"finished":",".join(finished)}
|
msg = {"mode":_MODE, "status":"started","bak_name":"complete","host":host,"cur_job":b,"start_time":STARTTIME,"end_time":"in progress","progress":0,"finished":",".join(finished)}
|
||||||
|
|
||||||
client.publish(topic, json.dumps(msg),qos=0, retain=True)
|
client2.publish(topic, json.dumps(msg),qos=0, retain=True)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -572,7 +572,7 @@ def backup_job(server):
|
|||||||
#print(len(apps))
|
#print(len(apps))
|
||||||
topic = "sectorq/amd/backups"
|
topic = "sectorq/amd/backups"
|
||||||
msg = {"mode":_MODE, "status":"started","bak_name":"complete","host":host,"cur_job":b,"sub":line[0],"start_time":STARTTIME,"end_time":"in progress","progress":str(round(progress)) + "%","finished":",".join(finished)}
|
msg = {"mode":_MODE, "status":"started","bak_name":"complete","host":host,"cur_job":b,"sub":line[0],"start_time":STARTTIME,"end_time":"in progress","progress":str(round(progress)) + "%","finished":",".join(finished)}
|
||||||
client.publish(topic, json.dumps(msg),qos=0, retain=False)
|
client2.publish(topic, json.dumps(msg),qos=0, retain=False)
|
||||||
progress = progress + step
|
progress = progress + step
|
||||||
|
|
||||||
cmnd = f"rm -rf {FULL_BACKUP_LATEST}"
|
cmnd = f"rm -rf {FULL_BACKUP_LATEST}"
|
||||||
@@ -631,7 +631,7 @@ def backup_job(server):
|
|||||||
#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}
|
||||||
finished.append(b)
|
finished.append(b)
|
||||||
msg = {"mode":_MODE, "status":"finished","bak_name":"complete","host":host,"cur_job":b,"start_time":ENDTIME,"end_time":"in progress","progress":0,"finished":",".join(finished)}
|
msg = {"mode":_MODE, "status":"finished","bak_name":"complete","host":host,"cur_job":b,"start_time":ENDTIME,"end_time":"in progress","progress":0,"finished":",".join(finished)}
|
||||||
client.publish(topic, json.dumps(msg),qos=0, retain=True)
|
client2.publish(topic, json.dumps(msg),qos=0, retain=True)
|
||||||
|
|
||||||
logging.info("Getting size of FS")
|
logging.info("Getting size of FS")
|
||||||
cmnd = "df -h /mnt/raid|awk '{ print $3 }'|tail -1"
|
cmnd = "df -h /mnt/raid|awk '{ print $3 }'|tail -1"
|
||||||
@@ -646,12 +646,12 @@ def backup_job(server):
|
|||||||
msg = {"mode":_MODE, "status":"finished","bak_name":"complete","host":host,"cur_job":b,"start_time":STARTTIME,"end_time":ENDTIME,"progress":0,"finished":",".join(finished),"used_space":used_space}
|
msg = {"mode":_MODE, "status":"finished","bak_name":"complete","host":host,"cur_job":b,"start_time":STARTTIME,"end_time":ENDTIME,"progress":0,"finished":",".join(finished),"used_space":used_space}
|
||||||
logging.info(msg)
|
logging.info(msg)
|
||||||
|
|
||||||
client.publish(topic, json.dumps(msg),qos=0, retain=True)
|
client2.publish(topic, json.dumps(msg),qos=0, retain=True)
|
||||||
topic = "sectorq/backups/start"
|
topic = "sectorq/backups/start"
|
||||||
logging.info(f"LALA : {topic}")
|
logging.info(f"LALA : {topic}")
|
||||||
client.publish(topic, "finished",qos=2, retain=True)
|
client2.publish(topic, "finished",qos=0, retain=True)
|
||||||
client.publish(topic, "finished2",qos=2, retain=True)
|
client2.publish(topic, "finished2",qos=0, retain=True)
|
||||||
client.disconnect()
|
client2.disconnect()
|
||||||
#return "finished"
|
#return "finished"
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user