From d682178a08f7b608c33c4e3d7c5afc88e08d7206 Mon Sep 17 00:00:00 2001 From: librelad Date: Sat, 23 May 2026 14:51:43 +0100 Subject: [PATCH] feat(backup): configurable Default Backup Location; simplify Path Mode label Automatic path mode hardcoded /docker/backups/, baked into the Path Mode dropdown label. Add a CFG_BACKUP_DEFAULT_PATH option in the Backup Engine config ("Default Backup Location", default /docker/backups) and have backupLocationResolvedPath build the auto path from it (/, trailing slash tolerated). Defaults to the old path, so existing auto locations are unchanged. Path Mode's option is now just "Automatic" (no inline path); its tooltip points at the Default Backup Location config option instead. Co-Authored-By: Claude Opus 4.7 Signed-off-by: librelad --- configs/backup/backup_engine | 1 + configs/backup/locations/1/location.config | 2 +- .../libreportal/frontend/js/components/backup/backup-page.js | 2 +- scripts/backup/locations/location_add.sh | 2 +- scripts/backup/locations/location_paths.sh | 5 ++++- 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/configs/backup/backup_engine b/configs/backup/backup_engine index e2465a5..af9d866 100644 --- a/configs/backup/backup_engine +++ b/configs/backup/backup_engine @@ -2,6 +2,7 @@ # Backup Engine - **ADVANCED** Engine-level knobs most users won't need to touch # ================================================================================ CFG_BACKUP_ENGINE=restic # Default Backup Engine - Fallback engine for new locations (each location can override) [restic:Restic|borg:BorgBackup|kopia:Kopia] +CFG_BACKUP_DEFAULT_PATH=/docker/backups # Default Backup Location - Base directory for locations set to Automatic path mode; each location lives in its own numbered subfolder (/) CFG_BACKUP_STRATEGY=stop-snapshot-start # Backup Strategy - How containers are quiesced before snapshotting [stop-snapshot-start:Stop → snapshot → start (safe default)|pause-snapshot-unpause:Pause → snapshot → unpause (less downtime)|live:Live — snapshot while running (only with DB dump hooks)] CFG_BACKUP_VERIFY_AFTER=true # Verify After Backup - Run integrity check after each backup CFG_BACKUP_VERIFY_DATA_PERCENT=5 # Verify Data Sample % - Percentage of repo data to checksum-verify weekly diff --git a/configs/backup/locations/1/location.config b/configs/backup/locations/1/location.config index 308ef4e..5f7107a 100644 --- a/configs/backup/locations/1/location.config +++ b/configs/backup/locations/1/location.config @@ -5,7 +5,7 @@ CFG_BACKUP_LOC_1_ENABLED=true # Enabled - Snap CFG_BACKUP_LOC_1_ENGINE=restic # Engine - Backup engine used at this location [restic:Restic|borg:BorgBackup|kopia:Kopia] **ADVANCED** CFG_BACKUP_LOC_1_PASSWORD=RANDOMIZEDPASSWORD1 # Repository Password - Used to encrypt/decrypt snapshots — back up offline! CFG_BACKUP_LOC_1_TYPE=local # Type - Backend [local:Local / mounted path|sftp:SFTP|rest:REST|s3:S3|b2:Backblaze B2|gs:Google Cloud Storage|azure:Azure|rclone:rclone] -CFG_BACKUP_LOC_1_PATH_MODE=auto # Path Mode - Where this location stores its data [auto:Automatic (/docker/backups/)|custom:Custom path] +CFG_BACKUP_LOC_1_PATH_MODE=auto # Path Mode - Automatic uses the Default Backup Location from the Backup Engine config (one subfolder per location); Custom uses the path below [auto:Automatic|custom:Custom path] CFG_BACKUP_LOC_1_PATH= # Custom Path - Filesystem path on this server (used when Path Mode = Custom) CFG_BACKUP_LOC_1_URI= # URI Override - Custom restic URI (leave blank to build from the fields below) **ADVANCED** CFG_BACKUP_LOC_1_SSH_USER= # SSH User - For sftp type diff --git a/containers/libreportal/frontend/js/components/backup/backup-page.js b/containers/libreportal/frontend/js/components/backup/backup-page.js index 963fc84..d5c0dc8 100644 --- a/containers/libreportal/frontend/js/components/backup/backup-page.js +++ b/containers/libreportal/frontend/js/components/backup/backup-page.js @@ -29,7 +29,7 @@ const BACKUP_LOC_FIELD_DEFS = { ENABLED: { title: 'Enabled', description: 'Push backups to this location.' }, ENGINE: { title: 'Engine', description: 'Backup engine used at this location.' }, TYPE: { title: 'Type', description: 'Backend the engine uses to talk to this location.' }, - PATH_MODE: { title: 'Path', description: 'Automatic puts the repo at /docker/backups/. Pick Custom to use a specific path (e.g. an attached drive or a NAS mount).' }, + PATH_MODE: { title: 'Path Mode', description: 'Automatic uses the Default Backup Location from the Backup Engine config (one subfolder per location). Pick Custom to use a specific path (e.g. an attached drive or a NAS mount).' }, PATH: { title: 'Custom path', description: 'Filesystem path on this server. Used only when Path is set to Custom.' }, URI: { title: 'Repository URI (override)', description: 'Custom restic URI — leave blank to build from the fields below.' }, SSH_USER: { title: 'SSH user', description: '' }, diff --git a/scripts/backup/locations/location_add.sh b/scripts/backup/locations/location_add.sh index f5506c9..49deb71 100644 --- a/scripts/backup/locations/location_add.sh +++ b/scripts/backup/locations/location_add.sh @@ -35,7 +35,7 @@ locationAdd() echo "CFG_BACKUP_LOC_${idx}_ENGINE=${default_engine} # Engine - Backup engine used at this location [restic:Restic|borg:BorgBackup|kopia:Kopia] **ADVANCED**" echo "CFG_BACKUP_LOC_${idx}_PASSWORD=RANDOMIZEDPASSWORD1 # Repository Password - Used to encrypt/decrypt snapshots — back up offline!" echo "CFG_BACKUP_LOC_${idx}_TYPE=${type} # Type - Backend [local:Local / mounted path|sftp:SFTP|rest:REST|s3:S3|b2:Backblaze B2|gs:Google Cloud Storage|azure:Azure|rclone:rclone]" - echo "CFG_BACKUP_LOC_${idx}_PATH_MODE=${default_path_mode} # Path Mode - Where this location stores its data [auto:Automatic (/docker/backups/)|custom:Custom path]" + echo "CFG_BACKUP_LOC_${idx}_PATH_MODE=${default_path_mode} # Path Mode - Automatic uses the Default Backup Location from the Backup Engine config (one subfolder per location); Custom uses the path below [auto:Automatic|custom:Custom path]" echo "CFG_BACKUP_LOC_${idx}_PATH=${default_path} # Custom Path - Filesystem path on this server (used when Path Mode = Custom)" echo "CFG_BACKUP_LOC_${idx}_URI= # URI Override - Custom restic URI (leave blank to build from the fields below) **ADVANCED**" echo "CFG_BACKUP_LOC_${idx}_SSH_USER= # SSH User - For sftp type" diff --git a/scripts/backup/locations/location_paths.sh b/scripts/backup/locations/location_paths.sh index 63d80eb..e176824 100644 --- a/scripts/backup/locations/location_paths.sh +++ b/scripts/backup/locations/location_paths.sh @@ -67,7 +67,10 @@ backupLocationResolvedPath() local mode mode=$(resticLocationField "$idx" PATH_MODE) if [[ "$mode" == "auto" ]]; then - echo "$docker_dir/backups/${idx}" + # Base dir is the configurable Default Backup Location (Backup Engine + # config); each location gets its own numbered subfolder. + local base="${CFG_BACKUP_DEFAULT_PATH:-$docker_dir/backups}" + echo "${base%/}/${idx}" else resticLocationField "$idx" PATH fi