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