Fix exit code and success check for remote backups
The remote branch of run() returned None, so the program always exited with 0, and it decided whether the backup worked by checking that the backup folder existed on the server, ignoring rsync's return code. Use the same return code check for local and remote backups.
This commit is contained in:
@@ -615,23 +615,8 @@ class Backup:
|
||||
if self._remote:
|
||||
assert self._ssh is not None
|
||||
|
||||
_, stdout, _ = self._ssh.exec_command(
|
||||
f'if [ -d "{self._output_dir}" ]; then echo "ok"; fi')
|
||||
|
||||
output = stdout.read().decode('utf-8').strip()
|
||||
|
||||
if output == 'ok':
|
||||
logger.info('Backup completed')
|
||||
|
||||
_notify('Backup completed')
|
||||
else:
|
||||
logger.error('Backup failed')
|
||||
|
||||
_notify('Backup failed (check log for details)')
|
||||
|
||||
if self._ssh:
|
||||
self._ssh.close()
|
||||
else:
|
||||
|
||||
if returncode != 0:
|
||||
logger.error(
|
||||
'Some errors occurred while performing the backup')
|
||||
|
||||
Reference in New Issue
Block a user