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

parse folder name instead of modification time which is preserved by rsync,...

parse folder name instead of modification time which is preserved by rsync, fix return code, fixes #21677
parent 4cd2d756
No related branches found
No related tags found
No related merge requests found
...@@ -78,12 +78,14 @@ def check_local_backup(path): ...@@ -78,12 +78,14 @@ def check_local_backup(path):
print('Checking %s' % backup_folder) print('Checking %s' % backup_folder)
latest = os.path.join(backup_folder, 'latest') latest = os.path.join(backup_folder, 'latest')
if os.path.exists(latest): if os.path.exists(latest):
mtime = os.path.getmtime(latest) # resolve symbolic link
d = datetime.fromtimestamp(mtime) latest = os.path.realpath(latest)
date = os.path.basename(latest)
d = datetime.strptime(date, '%Y-%m-%d-%H%M%S')
now = datetime.now() now = datetime.now()
diff_seconds = (now - d).total_seconds() diff_seconds = (now - d).total_seconds()
if diff_seconds > 48*3600: if diff_seconds > 24*3600:
print_red('Backup %s is older than 48h (%ih)' % (backup_folder, diff_seconds/3600)) print_red('Backup %s is older than 24h (%ih)' % (backup_folder, diff_seconds/3600))
all_ok = False all_ok = False
else: else:
print_green('Backup %s is fine' % backup_folder) print_green('Backup %s is fine' % backup_folder)
...@@ -126,7 +128,7 @@ if os.path.isfile('../utils.py'): ...@@ -126,7 +128,7 @@ if os.path.isfile('../utils.py'):
else: else:
sys.exit(0) sys.exit(0)
elif LOCAL_BACKUP_FOLDERS: elif LOCAL_BACKUP_FOLDERS:
sys.exit(check_local_backups(LOCAL_BACKUP_FOLDERS)) sys.exit(not check_local_backups(LOCAL_BACKUP_FOLDERS))
else: else:
print('No BACKUP_SERVER defined in config, untestable') print('No BACKUP_SERVER defined in config, untestable')
sys.exit(2) sys.exit(2)
......
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