diff --git a/tests/test_backup.py b/tests/test_backup.py index e9f7cee556ba4cd450ca0e7ac6388a9cfced97cd..28e16dc9a77415dbd37d0a9721b458e57e12ce39 100755 --- a/tests/test_backup.py +++ b/tests/test_backup.py @@ -9,6 +9,7 @@ import os import sys import subprocess import imp +from datetime import datetime os.chdir(os.path.dirname(__file__)) @@ -21,8 +22,13 @@ def test_last_backup_is_recent(server, client): cmd = 'ssh %s ls -l %s | grep current' % (server, path) status, out = subprocess.getstatusoutput(cmd) if status == 0: - date = out.strip().split(' ')[-1] - print(date) + date = out.strip().split(' ')[-2] + pdate = datetime.strptime(date, '%Y-%m-%d') + if datetime.now() - pdate > 2: + print('Backup is older than 2 days') + return False + else: + return True else: return False