diff --git a/tests/test_backup.py b/tests/test_backup.py index 75404d393e176290532c15f30ea7f3b2bcd64bb6..cfea1332c8c91d08513ed9a5659c568bad3c53be 100755 --- a/tests/test_backup.py +++ b/tests/test_backup.py @@ -78,12 +78,14 @@ def check_local_backup(path): print('Checking %s' % backup_folder) latest = os.path.join(backup_folder, 'latest') if os.path.exists(latest): - mtime = os.path.getmtime(latest) - d = datetime.fromtimestamp(mtime) + # resolve symbolic link + latest = os.path.realpath(latest) + date = os.path.basename(latest) + d = datetime.strptime(date, '%Y-%m-%d-%H%M%S') now = datetime.now() diff_seconds = (now - d).total_seconds() - if diff_seconds > 48*3600: - print_red('Backup %s is older than 48h (%ih)' % (backup_folder, diff_seconds/3600)) + if diff_seconds > 24*3600: + print_red('Backup %s is older than 24h (%ih)' % (backup_folder, diff_seconds/3600)) all_ok = False else: print_green('Backup %s is fine' % backup_folder) @@ -126,7 +128,7 @@ if os.path.isfile('../utils.py'): else: sys.exit(0) elif LOCAL_BACKUP_FOLDERS: - sys.exit(check_local_backups(LOCAL_BACKUP_FOLDERS)) + sys.exit(not check_local_backups(LOCAL_BACKUP_FOLDERS)) else: print('No BACKUP_SERVER defined in config, untestable') sys.exit(2)