From 839cf3561aa56bdfb8b7e8cb9696df5e70fcc150 Mon Sep 17 00:00:00 2001 From: librelad Date: Tue, 26 May 2026 00:27:25 +0100 Subject: [PATCH] feat(cli): backup system / restore system subcommands MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Expose the system-config backup on demand (not just within 'backup all'): - `libreportal backup system` -> backupSystemConfig (snapshot the system config — settings, WebUI creds, backup-location creds — to all enabled locations) - `libreportal restore system [loc_idx]` -> backupRestoreSystemConfig (restore the latest system snapshot into a staging dir; never overwrites live config) Distinct from the existing 'restore migrate system' (which restores all *apps* from another host). Help text updated for both. Routing verified with stubs. Co-Authored-By: Claude Opus 4.7 Signed-off-by: librelad --- scripts/cli/commands/backup/cli_backup_commands.sh | 3 +++ scripts/cli/commands/backup/cli_backup_header.sh | 6 +++++- scripts/cli/commands/restore/cli_restore_commands.sh | 5 +++++ scripts/cli/commands/restore/cli_restore_header.sh | 4 ++++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/scripts/cli/commands/backup/cli_backup_commands.sh b/scripts/cli/commands/backup/cli_backup_commands.sh index 20fb4eb..5361d37 100755 --- a/scripts/cli/commands/backup/cli_backup_commands.sh +++ b/scripts/cli/commands/backup/cli_backup_commands.sh @@ -54,6 +54,9 @@ cliHandleBackupCommands() all) backupAllApps ;; + system) + backupSystemConfig + ;; scheduled) backupScheduleEnabledApps ;; diff --git a/scripts/cli/commands/backup/cli_backup_header.sh b/scripts/cli/commands/backup/cli_backup_header.sh index 95a060a..729970a 100755 --- a/scripts/cli/commands/backup/cli_backup_header.sh +++ b/scripts/cli/commands/backup/cli_backup_header.sh @@ -19,7 +19,11 @@ cliShowBackupHelp() echo " Delete every backup for an app (skips append-only locations)." echo "" echo "backup all" - echo " Snapshot every installed app." + echo " Snapshot every installed app (also runs 'backup system')." + echo "" + echo "backup system" + echo " Snapshot the system config (settings, WebUI creds, backup-location" + echo " creds) to all enabled locations — needed for a self-sufficient restore." echo "" echo "backup scheduled" echo " Queue a backup for every app with backups enabled (daily cron entry)." diff --git a/scripts/cli/commands/restore/cli_restore_commands.sh b/scripts/cli/commands/restore/cli_restore_commands.sh index 12b4e9b..7304274 100755 --- a/scripts/cli/commands/restore/cli_restore_commands.sh +++ b/scripts/cli/commands/restore/cli_restore_commands.sh @@ -36,6 +36,11 @@ cliHandleRestoreCommands() ;; esac ;; + system) + # Restore the latest system-config snapshot (settings + creds) into a + # staging dir; never overwrites live config. Optional location idx. + backupRestoreSystemConfig "$action" + ;; migrate) case "$action" in app) diff --git a/scripts/cli/commands/restore/cli_restore_header.sh b/scripts/cli/commands/restore/cli_restore_header.sh index 39c45be..6c1d6cc 100755 --- a/scripts/cli/commands/restore/cli_restore_header.sh +++ b/scripts/cli/commands/restore/cli_restore_header.sh @@ -9,6 +9,10 @@ cliShowRestoreHelp() echo "restore app list " echo " List available backups for an app across all enabled locations." echo "" + echo "restore system [loc_idx]" + echo " Restore the latest system-config snapshot into a staging dir" + echo " (review-then-copy; never overwrites live config). Default: first location." + echo "" echo "restore migrate app [loc_idx]" echo " Restore one app's backup taken on another host (cross-host migrate)." echo ""