From 5ab91b01f7dc5325efcce820225ec0b499c98374 Mon Sep 17 00:00:00 2001 From: brent s Date: Wed, 25 Oct 2017 16:28:08 -0400 Subject: [PATCH] ... --- storage/backups/borg/backup.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/storage/backups/borg/backup.py b/storage/backups/borg/backup.py index 4154f6a..96a5d23 100755 --- a/storage/backups/borg/backup.py +++ b/storage/backups/borg/backup.py @@ -108,7 +108,7 @@ class Backup(object): with open(os.devnull, 'w') as DEVNULL: _err = subprocess.run(cmd, stdout = DEVNULL, stderr = subprocess.PIPE).stderr.decode('utf-8').strip() if _err != '': - self.logger.error('STDERR: {0} ({1})'.format(_out.stderr.decode('utf-8'), + self.logger.error('STDERR: {0} ({1})'.format(_err.stderr.decode('utf-8'), ' '.join(cmd))) return() @@ -134,11 +134,14 @@ class Backup(object): stderr = subprocess.PIPE) _stdout = _out.stdout.decode('utf-8').strip() _stderr = _out.stderr.decode('utf-8').strip() + _returncode = _out.returncode self.logger.debug('[{0}]: (RESULT) {1}'.format(r, _stdout)) - if _stderr != '': - self.logger.error('[{0}]: STDERR: {1} ({2})'.format(r, - _stderr, - ' '.join(_cmd))) + # sigh. borg uses stderr for verbose output. + self.logger.debug('[{0}]: STDERR: ({2})\n{1}'.format(r, + _stderr, + ' '.join(_cmd))) + if _returncode != 0: + self.logger.error('[{0}]: FAILED: {1}'.format(r, ' '.join(_cmd))) del(_env['BORG_PASSPHRASE']) self.logger.info('[{0}]: END INITIALIZATION'.format(r)) return() @@ -179,11 +182,13 @@ class Backup(object): stderr = subprocess.PIPE) _stdout = _out.stdout.decode('utf-8').strip() _stderr = _out.stderr.decode('utf-8').strip() + _returncode = _out.returncode self.logger.debug('[{0}]: (RESULT) {1}'.format(r, _stdout)) - if _stderr != '': - self.logger.error('[{0}]: STDERR: {1} ({2})'.format(r, - _stderr, - ' '.join(_cmd))) + self.logger.error('[{0}]: STDERR: ({2})\n{1}'.format(r, + _stderr, + ' '.join(_cmd))) + if _returncode != 0: + self.logger.error('[{0}]: FAILED: {1}'.format(r, ' '.join(_cmd))) del(_env['BORG_PASSPHRASE']) self.logger.info('[{0}]: END BACKUP'.format(r)) self.logger.info('END: backup')