Files
ubuntu-post-install/services
Claude d2568ecb09 Read back existing destinations, ntfy, schedule, and B2 fields on rerun
Requested after a rerun silently reset DR_SYNC_PATH (fixed separately) —
auditing the rest of install_backup() turned up the same class of bug in
several other places, one of them worse than the one that prompted this:

- Default destination repo path defaulted to $ACTUAL_HOME/backups/... even
  when the real configured repo was somewhere else entirely (this user's
  actual path is /root/backups/kopia-backup) — accepting the shown default
  on a rerun would have pointed the installer at the wrong location.
- Extra (non-"default") destinations weren't preserved AT ALL on a rerun —
  skipping "Add more destinations?" silently dropped every extra
  destination, and anything mapped to it, from the rewritten backup.conf.
- The per-service destination-assignment prompt always showed "[default]"
  regardless of the service's actual existing mapping.
- ntfy URL/token always started blank, silently disabling notifications on
  any rerun where they weren't retyped.
- The schedule prompt always defaulted to option 1 (daily 02:00) instead of
  reading back whatever OnCalendar was actually already running.
- B2's four sub-fields (bucket/endpoint/key ID/secret) always started
  blank even when reconfiguring an already-working REMOTE_TYPE=s3 setup —
  a mispaste on any one of the four meant retyping all four blind, since
  there was nothing to fall back to per-field (the existing REMOTE_ARGS was
  already preserved as a whole on a blank/failed attempt, just not offered
  back as individual editable defaults).

All six read the same way: pull the existing value from backup.conf (or,
for the schedule, from the live systemd timer unit — schedule isn't stored
in backup.conf) and use it as the prompt default, so accepting the default
keeps what's already there instead of silently reverting it. Verified all
six against a mock backup.conf + timer fixture with pre-existing values for
every field this touches.

Known remaining gap: KEEP_LATEST (retention count) still isn't read back —
doing so correctly needs the repo already connected, which happens later
in this same function's flow. Flagging rather than rushing a reorder here.
2026-08-14 22:51:37 +00:00
..