Commit Graph
172 Commits
Author SHA1 Message Date
Fuxino 7091118663 Handle SSH connection errors instead of crashing
An unknown hostname, a refused connection or an unreachable server
raise OSError (socket.gaierror, NoValidConnectionsError), which
paramiko.SSHException doesn't cover, so the program crashed with a
traceback. Log the error and exit with code 5 instead.
2026-10-08 20:14:39 +02:00
Fuxino 3113e182c7 Treat rsync return code 24 as success
Code 24 (source files vanished during the transfer) already counted as
success when deciding whether to remove old backups, but the program
still exited with 4 and reported errors. Exit with 0 and report the
backup as completed, logging only a warning, so both checks agree.
2026-10-08 20:12:29 +02:00
Fuxino 8fc3c42a5e 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.
2026-10-08 20:10:52 +02:00
Fuxino 0671f86579 Fix SSH key loading for ed25519 and ECDSA keys
Unencrypted ed25519 and ECDSA keys crashed with an uncaught
SSHException, and the DSA fallback raised NameError since paramiko 4
removed DSSKey. Load the key with paramiko.PKey.from_path instead,
ask for the passphrase only when the key is encrypted, and log an
error instead of crashing when the key can't be loaded.

Require paramiko >= 3.2 for PKey.from_path.
2026-10-08 20:06:57 +02:00
Fuxino 2f207efcf9 Update PKGBUILD 2026-10-08 18:25:08 +02:00
Fuxino 3cbca8e4d8 Bump version to 4.2.0 4.2.0 2026-10-08 18:23:03 +02:00
Fuxino 54880651be Fix outdated and wrong information in README
Use git.shouldnt.work as the clone URL, don't install wheel for
building, as setuptools no longer needs it, list paramiko among the
optional dependencies, and use the correct names of the remote
backup options (--ssh-user, --ssh-host).
2026-10-08 18:19:35 +02:00
Fuxino 793a30fad8 Remove unused python-dotenv dependency
load_dotenv() was called, but no setting was ever read from a .env
file. Drop it from the code, pyproject.toml, PKGBUILD and README.
2026-10-08 18:15:07 +02:00
Fuxino 871dd0f49a Warn if a backup fails after old backups were removed
With --remove-before-backup, a failed backup leaves only the kept
backups, or none with keep=0. Log an error and send a notification
in that case, and document it in the man page.
2026-10-08 18:13:13 +02:00
Fuxino 30e4416f8f Look for the last backup after removing old ones
With --remove-before-backup, the last backup was selected for
--link-dest before old backups were removed, so with keep=0 rsync
was given a directory that no longer existed.
2026-10-08 18:11:25 +02:00
Fuxino d0f888cbb4 Always use --mkpath and --ignore-missing-args with rsync
With --rsync-options, only -r and -v were kept, so the first backup
failed because the simple_backup directory did not exist yet, and a
missing input made rsync fail. Use these options in any case.
2026-10-08 18:08:28 +02:00
Fuxino 7ef29cf551 Report invalid config files instead of crashing
Invalid values (e.g. an empty or non-numeric 'keep') and syntax
errors in the config file raised uncaught exceptions. Catch them
and exit with code 6, including the reason in the error message.
2026-10-08 18:06:33 +02:00
Fuxino 4f5499eba9 Allow '%' in config file values
ConfigParser interpolation treats '%' as special, so a path or
pattern containing it crashed the program. Disable interpolation,
which is not used by the config file.
2026-10-08 18:05:11 +02:00
Fuxino fc165fccbf Only expand '~' at the start of config paths
Every '~' in inputs and backup_dir was replaced with '~user', so
paths like 'notes~' or '~otheruser' did not match. Expand only a
leading '~' or '~/'.
2026-10-08 18:04:25 +02:00
Fuxino d79ea56c0f Ignore whitespace around comma-separated config values
'inputs=/a, /b' was read as '/a' and ' /b', so /b was skipped, and
excluded patterns with spaces around them never matched. Strip
whitespace from each value, and ignore empty exclude entries.
2026-10-08 18:03:18 +02:00
Fuxino 5189910131 Don't use ':' in backup directory names
':' is not allowed on FAT/exFAT filesystems, so backups to such
drives failed. Use '%Y-%m-%d_%H-%M-%S' instead; existing backups
with the old format still sort correctly. Document the limitations
of FAT/exFAT in the man page.
2026-10-08 18:01:07 +02:00
Fuxino 7d4c43f8ff Always remove temp files and close their descriptors
The inputs temp file was left behind when no inputs existed, and
both temp files if rsync failed to start. The descriptors returned
by mkstemp were also never closed. Remove the temp files when run()
exits in any way, and write them through the mkstemp descriptors.
2026-10-08 17:58:32 +02:00
Fuxino ac7e6ec21b Don't print tracebacks when desktop notifications fail
Without dbus-python, or without a session bus (e.g. when running
from a timer), each notification printed a traceback. Skip
notifications if dbus is not installed, and log a single warning
if sending one fails. Remove the now unneeded NameError handling
around _notify calls.
2026-10-08 17:55:57 +02:00
Fuxino 578d992a19 Only turn warnings into errors where needed
warnings.filterwarnings('error') applied to the whole program, so
any warning raised by a library (e.g. a DeprecationWarning) would
crash it. Limit it to the ssh connection (unknown host key) and
the password prompt (no terminal available).
2026-10-08 17:50:47 +02:00
Fuxino e2d8897a45 Fix crash on Python < 3.14 when paramiko is not installed
The return annotation of _ssh_connect referenced paramiko, which
Python < 3.14 evaluates at class definition, raising NameError when
paramiko (an optional dependency) is missing. Postpone evaluation
of annotations, and mark the return type as Optional.
2026-10-08 17:47:02 +02:00
Fuxino dadc4b0265 Resolve default config path after the user is known
The default config path was computed before -u was parsed, so
running as root without sudo/doas used '~None/...' even when the
user was given with -u. Expand '~' only after the user is detected.
2026-10-08 17:45:02 +02:00
Fuxino 7e7d11c520 Detect the invoking user when running with doas
User detection only checked SUDO_USER, so with doas the user's
config file was not found unless -u was given. Fall back to
DOAS_USER, as already done for notifications.
2026-10-08 17:43:28 +02:00
Fuxino 22e0556b50 Document that old backups are kept if rsync fails 2026-10-08 17:41:17 +02:00
Fuxino 2b91178e94 Don't remove old backups if rsync fails
If rsync returns an error, the new backup may be incomplete. Keep
the old backups in that case, except for return code 24 (vanished
source files), which is expected when backing up a live system.
2026-10-08 17:38:34 +02:00
Fuxino 2c2649113d Fix relative input paths being silently skipped
rsync reads --files-from entries relative to the source directory
('/'), so relative inputs pointed to the wrong path and were ignored
due to --ignore-missing-args. Convert inputs to absolute paths.
2026-10-08 17:35:35 +02:00
Fuxino 0f4a100ac7 Move package metadata from setup.cfg to pyproject.toml
Drop python-wheel from PKGBUILD makedepends, as setuptools
builds wheels on its own.
2026-10-08 17:29:40 +02:00
Fuxino 60d83151dc Update PKGBUILD 2026-10-03 21:07:16 +02:00
Fuxino 47aec456be Fix notifications when using doas 4.1.7 2026-10-03 21:04:17 +02:00
Fuxino c715188973 Fix code with autopep8 2025-03-30 15:02:50 +02:00
Fuxino 57613649c2 Add missing type hints 2025-03-30 15:02:04 +02:00
Fuxino 67dbb49a67 Update PKGBUILD 2025-03-30 14:53:53 +02:00
Fuxino e62a668f3e Update metadata 4.1.6 2025-03-30 14:39:59 +02:00
Fuxino bd8934d57f Update version tag 2025-03-30 14:38:56 +02:00
Fuxino 96fe3c7813 Update man page 2025-03-30 14:38:29 +02:00
Fuxino 9fdb959540 Improve handling of user detection failure 2025-03-30 14:37:30 +02:00
Fuxino eb889beee7 Add Python 3.13 to setup.cfg 2025-03-30 12:16:04 +02:00
Fuxino 2a37eb4172 Add PKGBUILD 2024-11-13 19:38:12 +01:00
Fuxino 45a07205a1 Add type hints plus minor code fixes 4.1.5 2024-09-28 09:47:33 +02:00
Fuxino 9390cd2de8 Allow removing remote old backups with sudo if possible
If allowed by the remote server, try using sudo to remove
old backups (rm needs to be allowed in sudoers to run
without password)
4.1.4
2023-10-15 15:39:06 +02:00
Fuxino 77661c0964 Handle getpass exception 4.1.3 2023-07-16 08:22:51 +02:00
Fuxino e3a970217f Improve logging 4.1.2 2023-06-25 11:49:02 +02:00
Fuxino 8968fcd1a8 Fix parsing option bug 4.1.1 2023-06-25 10:12:07 +02:00
Fuxino 35b87c859e Add --user arg 4.1.0 2023-06-20 19:22:22 +02:00
Fuxino f3d5ebd276 Merge branch 'development' 4.0.2 2023-06-20 17:36:40 +02:00
Fuxino fb726a80ab Fix bug
Remove forgotten test code -.-
2023-06-20 17:36:12 +02:00
Fuxino 4701ee0b05 Fix typo 2023-06-19 16:00:21 +02:00
Fuxino dd779d242b Fix crash when config file missing 4.0.1 2023-06-18 22:58:53 +02:00
Fuxino 22a3e8d60f Make paramiko optional 2023-06-18 22:53:29 +02:00
Fuxino a26182cedd Update version number 4.0.0 2023-06-16 19:16:47 +02:00
Fuxino 5b3558c282 Merge branch 'development' 2023-06-16 19:15:44 +02:00