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

support local folder for backups checking, refs #21677

parent 3c4458bf
No related branches found
No related tags found
No related merge requests found
......@@ -108,8 +108,10 @@ BURP_MAIL_DEST='sysadmin@ubicast.eu'
BURP_CLIENT_NAME=
BURP_CLIENT_MAIL_DEST='sysadmin@ubicast.eu'
# -- tmbackup
# -- tmbackup.sh --
BACKUP_SERVER=''
# CSV separated
LOCAL_BACKUP_FOLDERS='/backup'
# -- FTP --
# move uploaded files into hotfolder
......
......@@ -67,11 +67,42 @@ def test_backup_space(server):
return False
def check_local_backup(path):
for d in os.listdir(path):
subd = os.path.join(path, d)
latest = os.path.join(subd, 'latest')
if os.exists(latest):
mtime = os.path.getmtime(latest)
d = datetime.fromtimestamp(mtime)
now = datetime.now()
diff_seconds = (now - d).total_seconds()
if diff_seconds > 25*3600:
print('Backup %s is older than a day' % subd)
return False
else:
print('Backup %s is fine' % subd)
return True
else:
print('Backup %s is not okay (no %s file)' % (subd, latest))
return False
def check_local_backups(paths):
all_ok = True
blacklist = ('lost+found')
folders = paths.split(',')
for f in folders:
if f not in blacklist:
all_ok = min(check_local_backup(f), all_ok)
return all_ok
os.chdir(os.path.dirname(__file__))
if os.path.isfile('../utils.py'):
es_utils = imp.load_source('es_utils', '../utils.py')
conf = es_utils.load_conf()
BACKUP_SERVER = conf.get('BACKUP_SERVER')
LOCAL_BACKUP_FOLDERS = conf.get('LOCAL_BACKUP_FOLDERS')
if BACKUP_SERVER:
if not test_ssh(BACKUP_SERVER):
print('Failed to ssh into backup server')
......@@ -84,6 +115,8 @@ if os.path.isfile('../utils.py'):
sys.exit(1)
else:
sys.exit(0)
elif LOCAL_BACKUP_FOLDERS:
sys.exit(check_local_backups(LOCAL_BACKUP_FOLDERS))
else:
print('No BACKUP_SERVER defined in config, untestable')
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