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,37 +615,22 @@ class Backup:
|
|||||||
if self._remote:
|
if self._remote:
|
||||||
assert self._ssh is not None
|
assert self._ssh is not None
|
||||||
|
|
||||||
_, stdout, _ = self._ssh.exec_command(
|
self._ssh.close()
|
||||||
f'if [ -d "{self._output_dir}" ]; then echo "ok"; fi')
|
|
||||||
|
|
||||||
output = stdout.read().decode('utf-8').strip()
|
if returncode != 0:
|
||||||
|
logger.error(
|
||||||
|
'Some errors occurred while performing the backup')
|
||||||
|
|
||||||
if output == 'ok':
|
_notify(
|
||||||
logger.info('Backup completed')
|
'Some errors occurred while performing the backup. Check log for details')
|
||||||
|
|
||||||
_notify('Backup completed')
|
return 4
|
||||||
else:
|
|
||||||
logger.error('Backup failed')
|
|
||||||
|
|
||||||
_notify('Backup failed (check log for details)')
|
logger.info('Backup completed')
|
||||||
|
|
||||||
if self._ssh:
|
_notify('Backup completed')
|
||||||
self._ssh.close()
|
|
||||||
else:
|
|
||||||
if returncode != 0:
|
|
||||||
logger.error(
|
|
||||||
'Some errors occurred while performing the backup')
|
|
||||||
|
|
||||||
_notify(
|
return 0
|
||||||
'Some errors occurred while performing the backup. Check log for details')
|
|
||||||
|
|
||||||
return 4
|
|
||||||
|
|
||||||
logger.info('Backup completed')
|
|
||||||
|
|
||||||
_notify('Backup completed')
|
|
||||||
|
|
||||||
return 0
|
|
||||||
|
|
||||||
|
|
||||||
def _detect_user() -> Optional[str]:
|
def _detect_user() -> Optional[str]:
|
||||||
|
|||||||
Reference in New Issue
Block a user