From 10001a6b74998f328828830220b46290380046dd Mon Sep 17 00:00:00 2001 From: Jeremie Courreges-Anglas Date: Wed, 16 May 2018 16:26:47 +0200 Subject: [PATCH] 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 --- tisbackup.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tisbackup.py b/tisbackup.py index c4ca88b..35a3a6b 100755 --- a/tisbackup.py +++ b/tisbackup.py @@ -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)