bitwarden

This commit is contained in:
jaydee
2024-11-29 12:31:02 +01:00
parent a6b05df362
commit b19fcd1c66

View File

@@ -113,17 +113,17 @@ while hostdown:
time.sleep(5) time.sleep(5)
n += 1 n += 1
else: else:
print("host up") print("Backup host up " )
hostdown = False hostdown = False
port = 22 # Replace with the port you want to test port = 22 # Replace with the port you want to test
if is_port_open(BACKUP_HOST, port): n=0
print(f"Port {port} on {BACKUP_HOST} is open.") while not is_port_open(BACKUP_HOST, port):
else: print(f"Port {port} on {BACKUP_HOST} is closed. {n}\r", end="")
print(f"Port {port} on {BACKUP_HOST} is closed.") time.sleep(5)
sys.exit() n += 1
print(f"Port {port} on {BACKUP_HOST} is open.")
for b in backups[host]: for b in backups[host]:
topic = "sectorq/omv/backups/{}".format(b.lower()) topic = "sectorq/omv/backups/{}".format(b.lower())
@@ -161,6 +161,7 @@ for b in backups[host]:
status, output = subprocess.getstatusoutput(cmnd) status, output = subprocess.getstatusoutput(cmnd)
print("Create backup dir")
print(cmnd) print(cmnd)
@@ -172,6 +173,7 @@ for b in backups[host]:
ans = "y" ans = "y"
print(cmnd) print(cmnd)
print("Sync files")
if _TEST: if _TEST:
@@ -184,14 +186,17 @@ for b in backups[host]:
# input("????") # input("????")
status, output = subprocess.getstatusoutput(cmnd) status, output = subprocess.getstatusoutput(cmnd)
cmnd = f"ssh root@omv.home.lan 'rm -rf {FULL_BACKUP_LATEST}'" cmnd = f"ssh root@omv.home.lan 'rm -rf {FULL_BACKUP_LATEST}'"
print(cmnd)
#print(cmnd)
print("Removing latest link")
# input("????") # input("????")
status, output = subprocess.getstatusoutput(cmnd) status, output = subprocess.getstatusoutput(cmnd)
if _FIRST: if _FIRST:
cmnd = f"ssh root@omv.home.lan 'cd {NEW_BACKUP_DIR}; ln -s initial latest'" cmnd = f"ssh root@omv.home.lan 'cd {NEW_BACKUP_DIR}; ln -s initial latest'"
else: else:
cmnd = f"ssh root@omv.home.lan 'cd {NEW_BACKUP_DIR}; ln -s {DATETIME} latest'" 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("????") # input("????")
status, output = subprocess.getstatusoutput(cmnd) status, output = subprocess.getstatusoutput(cmnd)
@@ -200,8 +205,8 @@ for b in backups[host]:
print("Removing old dirs") print("Removing old dirs")
# input("????") # input("????")
#cmnd = "find {} -maxdepth 1 -type d -mtime +30 -exec rm -rf {{}} \;".format(BACKUP_DIR) #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 {{}} \;" cmnd = f"cd {NEW_BACKUP_DIR} find ./ -maxdepth 1 -type d -mmin +30 -exec rm -rf {{}} \\;"
print(cmnd) #print(cmnd)
# input("????") # input("????")
#status, output = subprocess.getstatusoutput(cmnd) #status, output = subprocess.getstatusoutput(cmnd)
now = datetime.datetime.now() now = datetime.datetime.now()
@@ -213,7 +218,7 @@ for b in backups[host]:
print("Getting size of FS") print("Getting size of FS")
#cmnd = "du -h --max-depth=0 {}".format(BACKUP_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) status, output = subprocess.getstatusoutput(cmnd)
used_space = (output.split())[0] used_space = (output.split())[0]
now = datetime.datetime.now() now = datetime.datetime.now()