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:
Fuxino
2026-10-08 20:10:52 +02:00
parent 0671f86579
commit 8fc3c42a5e
+10 -25
View File
@@ -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]: