Allow 'cleanup' to run when no space is left

Be conservative and only unlock the 'cleanup' functionality, else we'd
have to check that all other actions handle ENOSPC gracefully.

Noticed at Concept Hygiene: https://assistance.tranquil.it/scp/tickets.php?id=2010
This commit is contained in:
Jeremie Courreges-Anglas 2018-05-16 16:26:47 +02:00
parent 39859ffee1
commit 1bbea09f55

View File

@ -28,6 +28,7 @@ import sys
import getopt
import os.path
import logging
import errno
from libtisbackup.common import *
from libtisbackup.backup_mysql import backup_mysql
from libtisbackup.backup_rsync import backup_rsync
@ -369,9 +370,15 @@ def main():
# if we run the nagios check, we don't create log file, everything is piped to stdout
if action!='checknagios':
hdlr = logging.FileHandler(os.path.join(log_dir,'tisbackup_%s.log' % (backup_start_date)))
hdlr.setFormatter(logging.Formatter('%(asctime)s %(levelname)s %(message)s'))
logger.addHandler(hdlr)
try:
hdlr = logging.FileHandler(os.path.join(log_dir,'tisbackup_%s.log' % (backup_start_date)))
hdlr.setFormatter(logging.Formatter('%(asctime)s %(levelname)s %(message)s'))
logger.addHandler(hdlr)
except Exception, e:
if action == 'cleanup' and e.errno == errno.ENOSPC:
logger.warning("No space left on device, disabling file logging.")
else:
raise e
# Main
backup = tis_backup(dry_run=dry_run,verbose=verbose,backup_base_dir=backup_base_dir)