fix(sysbak): write config after sudo, not before#52
Merged
Conversation
Previously setup wrote ~/.config/sysbak/config before the sudo step. A failed sudo prompt (wrong password, sudo timeout) would clobber the user's backup_dirs and other customisations with defaults. Move the config write to after rsnapshot.conf is written successfully.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
~/.config/sysbak/configwrite to after the sudo step (rsnapshot.conf), not beforebackup_dirs,exclude_patterns, and staleness thresholds with defaultsRoot cause
Setup previously wrote the config file before calling
sudo tee /etc/rsnapshot.conf. If sudo failed (wrong password, timeout, or no terminal), the config was already overwritten with defaults — silently resetting any customisations.Discovered when a non-interactive run via Claude Code's Bash tool (no sudo terminal) clobbered a 7-entry
backup_dirsdown to 2 hardcoded defaults.Test plan
sysbak setupand enter wrong sudo password — config file unchangedsysbak setupwith correct sudo password — config written correctly after rsnapshot.confbackup_dirscustomisations survive a re-run