diff --git a/omv_backups_v3.py b/omv_backups_v3.py index 4032915..b4b4f04 100644 --- a/omv_backups_v3.py +++ b/omv_backups_v3.py @@ -113,17 +113,17 @@ while hostdown: time.sleep(5) n += 1 else: - print("host up") + print("Backup host up " ) hostdown = False port = 22 # Replace with the port you want to test -if is_port_open(BACKUP_HOST, port): - print(f"Port {port} on {BACKUP_HOST} is open.") -else: - print(f"Port {port} on {BACKUP_HOST} is closed.") - sys.exit() - - +n=0 +while not is_port_open(BACKUP_HOST, port): + print(f"Port {port} on {BACKUP_HOST} is closed. {n}\r", end="") + time.sleep(5) + n += 1 +print(f"Port {port} on {BACKUP_HOST} is open.") + for b in backups[host]: topic = "sectorq/omv/backups/{}".format(b.lower()) @@ -161,6 +161,7 @@ for b in backups[host]: status, output = subprocess.getstatusoutput(cmnd) + print("Create backup dir") print(cmnd) @@ -172,6 +173,7 @@ for b in backups[host]: ans = "y" print(cmnd) + print("Sync files") if _TEST: @@ -184,14 +186,17 @@ for b in backups[host]: # input("????") status, output = subprocess.getstatusoutput(cmnd) cmnd = f"ssh root@omv.home.lan 'rm -rf {FULL_BACKUP_LATEST}'" - print(cmnd) + + #print(cmnd) + print("Removing latest link") # input("????") status, output = subprocess.getstatusoutput(cmnd) if _FIRST: cmnd = f"ssh root@omv.home.lan 'cd {NEW_BACKUP_DIR}; ln -s initial latest'" else: cmnd = f"ssh root@omv.home.lan 'cd {NEW_BACKUP_DIR}; ln -s {DATETIME} latest'" - print(cmnd) + print("Creating new latest link") + #print(cmnd) # input("????") status, output = subprocess.getstatusoutput(cmnd) @@ -200,8 +205,8 @@ for b in backups[host]: print("Removing old dirs") # input("????") #cmnd = "find {} -maxdepth 1 -type d -mtime +30 -exec rm -rf {{}} \;".format(BACKUP_DIR) - cmnd = f"cd {NEW_BACKUP_DIR} find ./ -maxdepth 1 -type d -mmin +30 -exec rm -rf {{}} \;" - print(cmnd) + cmnd = f"cd {NEW_BACKUP_DIR} find ./ -maxdepth 1 -type d -mmin +30 -exec rm -rf {{}} \\;" + #print(cmnd) # input("????") #status, output = subprocess.getstatusoutput(cmnd) now = datetime.datetime.now() @@ -213,7 +218,7 @@ for b in backups[host]: print("Getting size of FS") #cmnd = "du -h --max-depth=0 {}".format(BACKUP_FS) -cmnd = "ssh root@omv.home.lan 'df -h /srv/dev-disk-by-uuid-02fbe97a-cd9a-4511-8bd5-21f8516353ee |awk '{ print $3 }'|tail -1'" +cmnd = "ssh root@omv.home.lan 'df -h /srv/dev-disk-by-uuid-2f843500-95b6-43b0-bea1-9b67032989b8|awk '{ print $3 }'|tail -1'" status, output = subprocess.getstatusoutput(cmnd) used_space = (output.split())[0] now = datetime.datetime.now()