Skip to content

Derive backup directory from KIAUH install root in BackupService#779

Closed
itdir wants to merge 13 commits intodw-0:masterfrom
itdir:master
Closed

Derive backup directory from KIAUH install root in BackupService#779
itdir wants to merge 13 commits intodw-0:masterfrom
itdir:master

Conversation

@itdir
Copy link

@itdir itdir commented Feb 25, 2026

Summary

  • Derive backup storage path from the KIAUH install root, placing kiauh_backups as a sibling directory to the repo.
  • Preserve the current behavior by falling back to Path.home() if repo root markers are not found.

Motivation

KIAUH is often installed outside the user’s home directory (e.g., /opt/kiauh). The current backup path always uses ~/kiauh_backups, which separates backups from the install location and can introduce permissions or maintenance issues, especially in environments with multiple admins. This change keeps backups colocated with the install root while keeping the existing default for unexpected layouts.

Implementation

  • Add _get_kiauh_root() to locate the repo root by searching parent directories for kiauh.sh and default.kiauh.cfg.
  • Set backup_root to <kiauh_root>/../kiauh_backups.
  • Fallback to Path.home() if markers are not found.

Testing

  • Manual:
    • KIAUH installed in /opt/kiauh → backups in /opt/kiauh_backups.
    • KIAUH installed in ~/kiauh → backups in ~/kiauh_backups.

itdir and others added 13 commits February 25, 2026 11:32
Update backup root initialization to use the path of the Kiauh root directory instead of only using home directory.
…ASE_DIR env var

Introduces a centralized BASE_DIR constant in core/constants.py that reads
from the KIAUH_BASE_DIR environment variable, defaulting to Path.home().
All component and extension directory constants now use BASE_DIR instead
of hardcoded Path.home() calls, enabling system-wide installs to /opt/*,
/srv/*, or any custom location.

Co-authored-by: itdir <41797199+itdir@users.noreply.github.com>
…rity

Co-authored-by: itdir <41797199+itdir@users.noreply.github.com>
…tory fallbacks

- Validate KIAUH_BASE_DIR: empty, whitespace-only, or relative paths safely
  fall back to Path.home() instead of producing unexpected behavior
- set_nginx_permissions(): always check home directory permissions (upstream
  behavior) plus BASE_DIR when it differs, since NGINX needs traversal access
- Backup fallback search: search both Path.home() and BASE_DIR when they
  differ, ensuring existing home-directory installs are always found

Co-authored-by: itdir <41797199+itdir@users.noreply.github.com>
Co-authored-by: itdir <41797199+itdir@users.noreply.github.com>
…ctory with full proposal

- Enhance BASE_DIR resolution: env var > kiauh.cfg > Path.home()
- Add base_dir to AppSettings and KiauhSettings for persistence
- Add base_dir option to default.kiauh.cfg (commented, self-documenting)
- Add startup logging when non-default base dir is active
- Create docs/proposal-configurable-base-dir.md with full analysis, SWOT,
  pros/cons, migration guide, and justification for upstream maintainers

Co-authored-by: itdir <41797199+itdir@users.noreply.github.com>
…oject_root validation, config example

Co-authored-by: itdir <41797199+itdir@users.noreply.github.com>
Configurable base directory with settings integration and upstream proposal
…ths"

This reverts commit 2c0044f, reversing
changes made to f1ea375.
…E_DIR env var

Squashed commits:
- b9d030f Initial plan
- 8336ecd Replace hardcoded Path.home() with configurable BASE_DIR from KIAUH_BASE_DIR env var
- 7e3efd5 Address code review: fix fd leak in tempfile, rename variable for clarity
- c2aac00 Ensure backward compatibility: validate BASE_DIR, preserve home directory fallbacks
- 817406a Address code review: use shlex.quote for shell safety, use set for dedup
- a5bb03f Comprehensive alternative: settings-integrated configurable base directory with full proposal
- 2eabc25 Address code review: module-level imports, dual separator support, project_root validation, config example
settings-integrated configurable base directory with full justification
@dw-0
Copy link
Owner

dw-0 commented Feb 27, 2026

closed in favor of #780

@dw-0 dw-0 closed this Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants