From 8fc3c42a5e90fd4610fbc32e591f188c43f97811 Mon Sep 17 00:00:00 2001 From: Fuxino Date: Thu, 8 Oct 2026 20:10:52 +0200 Subject: [PATCH] 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. --- simple_backup/simple_backup.py | 35 ++++++++++------------------------ 1 file changed, 10 insertions(+), 25 deletions(-) diff --git a/simple_backup/simple_backup.py b/simple_backup/simple_backup.py index 36b3833..27cb4ca 100755 --- a/simple_backup/simple_backup.py +++ b/simple_backup/simple_backup.py @@ -615,37 +615,22 @@ 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') + self._ssh.close() - output = stdout.read().decode('utf-8').strip() + if returncode != 0: + logger.error( + 'Some errors occurred while performing the backup') - if output == 'ok': - logger.info('Backup completed') + _notify( + 'Some errors occurred while performing the backup. Check log for details') - _notify('Backup completed') - else: - logger.error('Backup failed') + return 4 - _notify('Backup failed (check log for details)') + logger.info('Backup completed') - if self._ssh: - self._ssh.close() - else: - if returncode != 0: - logger.error( - 'Some errors occurred while performing the backup') + _notify('Backup completed') - _notify( - 'Some errors occurred while performing the backup. Check log for details') - - return 4 - - logger.info('Backup completed') - - _notify('Backup completed') - - return 0 + return 0 def _detect_user() -> Optional[str]: