Skip to content
Snippets Groups Projects
Commit d628b7a0 authored by Florent Thiery's avatar Florent Thiery
Browse files

add space check for local backups too

parent e2513417
No related branches found
No related tags found
No related merge requests found
...@@ -55,8 +55,10 @@ def test_last_backup_is_recent(server): ...@@ -55,8 +55,10 @@ def test_last_backup_is_recent(server):
return False return False
def test_backup_space(server): def test_backup_space(server=None, path="/backup"):
cmd = 'ssh -o StrictHostKeyChecking=no %s df -h /backup | tail -n 1' % (server) cmd = 'df -h %s | tail -n 1' % path
if server:
cmd = 'ssh -o StrictHostKeyChecking=no %s ' % server + cmd
status, out = subprocess.getstatusoutput(cmd) status, out = subprocess.getstatusoutput(cmd)
if status == 0: if status == 0:
dev, total, used, free, used_perc, mount = out.strip().split() dev, total, used, free, used_perc, mount = out.strip().split()
...@@ -71,7 +73,6 @@ def test_backup_space(server): ...@@ -71,7 +73,6 @@ def test_backup_space(server):
print('Failed to check backup space') print('Failed to check backup space')
return False return False
def check_local_backup(path): def check_local_backup(path):
all_ok = True all_ok = True
backup_folder = os.path.dirname(path) backup_folder = os.path.dirname(path)
...@@ -106,6 +107,7 @@ def check_local_backups(paths): ...@@ -106,6 +107,7 @@ def check_local_backups(paths):
status, out = subprocess.getstatusoutput(cmd) status, out = subprocess.getstatusoutput(cmd)
for bf in out.split('\n'): for bf in out.split('\n'):
all_ok = min(check_local_backup(bf), all_ok) all_ok = min(check_local_backup(bf), all_ok)
all_ok = min(test_backup_space(path=f), all_ok)
return all_ok return all_ok
...@@ -123,7 +125,7 @@ if os.path.isfile('../utils.py'): ...@@ -123,7 +125,7 @@ if os.path.isfile('../utils.py'):
if not test_last_backup_is_recent(BACKUP_SERVER): if not test_last_backup_is_recent(BACKUP_SERVER):
sys.exit(1) sys.exit(1)
else: else:
if not test_backup_space(BACKUP_SERVER): if not test_backup_space(server=BACKUP_SERVER):
sys.exit(1) sys.exit(1)
else: else:
sys.exit(0) sys.exit(0)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment