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:
@@ -145,15 +145,6 @@ TOPIC = 'sectorq/backups/start'
|
||||
USERNAME = 'jaydee'
|
||||
PASSWORD = 'jaydee1'
|
||||
USE_TLS = False # Set to False if not using TLS
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
backups = {
|
||||
"nas": {
|
||||
"login": "admin@nas.home.lan",
|
||||
@@ -482,24 +473,10 @@ def restore_job():
|
||||
cmnd = "ssh root@amd.home.lan 'systemctl suspend &'"
|
||||
status, output = subprocess.getstatusoutput(cmnd)
|
||||
|
||||
def backup_job():
|
||||
def backup_job(server):
|
||||
logging.info(f'starting backup job')
|
||||
message = "start"
|
||||
topic = "sectorq/backups/start"
|
||||
message= "finished1"
|
||||
client.publish(topic, message,qos=2,retain=True)
|
||||
return 0
|
||||
last = 1
|
||||
while True:
|
||||
directory = '/backups/'
|
||||
count = len(fnmatch.filter(os.listdir(directory), '*'))
|
||||
if last != count:
|
||||
logging.info(f'File Count: {count}')
|
||||
last = count
|
||||
if count == 0:
|
||||
time.sleep(10)
|
||||
continue
|
||||
else:
|
||||
finished = []
|
||||
now = datetime.datetime.now()
|
||||
STARTTIME = now.strftime("%Y-%m-%d_%H:%M:%S")
|
||||
@@ -513,13 +490,8 @@ def backup_job():
|
||||
# iterate over files in
|
||||
# that directory
|
||||
|
||||
for filename in os.scandir(directory):
|
||||
if filename.is_file():
|
||||
logging.info(filename.path)
|
||||
logging.info(filename.name)
|
||||
if filename.name == "restore":
|
||||
break
|
||||
host = filename.name
|
||||
|
||||
host = server
|
||||
logging.info("Backup")
|
||||
for b in backups[host]["jobs"]:
|
||||
|
||||
@@ -705,7 +677,6 @@ def backup_job():
|
||||
logging.info(msg)
|
||||
|
||||
send_mqtt_message(msg)
|
||||
os.remove(filename.path)
|
||||
|
||||
|
||||
topic = "sectorq/amd/restore"
|
||||
@@ -780,6 +751,9 @@ def backup_job():
|
||||
# print(x.text)
|
||||
# except:
|
||||
# pass
|
||||
message= "finished1"
|
||||
client.publish(topic, message,qos=2,retain=True)
|
||||
return 0
|
||||
|
||||
if _SSH_TEST:
|
||||
user = "root"
|
||||
|
Reference in New Issue
Block a user