diff --git a/omv_backup.py b/omv_backup.py index 9d44b63..37aa19c 100755 --- a/omv_backup.py +++ b/omv_backup.py @@ -26,6 +26,8 @@ def signal_handler(sig, frame): conn.close() sys.exit(0) + + signal.signal(signal.SIGINT, signal_handler) file_path = os.path.realpath(__file__) dir_path = os.path.dirname(file_path) @@ -50,6 +52,7 @@ status, output = subprocess.getstatusoutput(cmnd) if int(output) > 0: print("Running already!") sys.exit() + def is_port_open(host, port): try: sock = socket.create_connection((host, port)) @@ -208,7 +211,7 @@ def send_mqtt_message(topic,msg,qos=0,retain=False): client2.connect("mqtt.home.lan",1883,60) client2.publish(topic, json.dumps(msg), qos=qos, retain=retain) client2.disconnect() - logging.info(f"Message sent {topic}, {msg}") + logging.info(f"Message1 sent {topic}, {msg}") except ValueError as e: logging.error("Failed to send") print("Failed to send") @@ -642,6 +645,8 @@ def backup_job(server): topic = "sectorq/backups/start" logging.info(f"LALA : {topic}") send_mqtt_message(topic, "finished",qos=2,retain=True) + return "finished" + topic = "sectorq/amd/restore" for s in servers: