Skip to content

Keep one .env backup instead of one per run - #78

Merged
MCheli merged 1 commit into
mainfrom
session-bus/env-single-backup
Nov 25, 2026
Merged

MCheli merged 1 commit into
mainfrom
session-bus/env-single-backup

Conversation

@MCheli

@MCheli MCheli commented Nov 25, 2026

Copy link
Copy Markdown
Owner

Before

  • infrastructure/homelab-mcp/scripts/env_set.py copied .env to a new .env.bak-YYYYmmdd-HHMMSS on every run and never pruned. Six such copies built up on the server on 2026-11-22.
  • The Dependency-Track runbook (docs/dependency-track.md) made a dated .env.<date>-pre-deptrack.bak by hand.
  • .gitignore ignored .env.bak-* and *.env.backup but not a plain .env.bak.

After

  • env_set.py keeps a single .env.bak, mode 600, overwritten on every run. There's still at most one backup per run, and none when the input is refused.
  • The runbook step and its restore note use the same .env.bak.
  • .gitignore also ignores .env.bak and *.env.bak; the old patterns stay.
  • Tests updated, plus a new one: two runs leave exactly one backup (the previous .env), and a stale world-readable .env.bak is overwritten and set to 600.

Context: the 13 leftover .env copies on 83rr-poweredge were deleted today at Mark's request, after checking that nothing referenced them and that the live .env has every key they held (except the retired SENDGRID_API_KEY).

Testing

.venv/bin/python -m pytest -q infrastructure/homelab-mcp/tests → 76 passed. The repo has no CI workflows.

Deploy: env_set.py is a host script, run from the server checkout (the image copies only app/), so a git pull on the server makes it live. No rebuild needed.

🤖 Generated with Claude Code

https://claude.ai/code/session_01BTHimXjrtArDbsDweyjkYz

env_set.py made a new .env.bak-YYYYmmdd-HHMMSS copy of the secrets on
every run and never pruned them (six piled up on the server on
2026-11-22 alone). It now keeps a single .env.bak, overwritten each run,
mode 600. The Dependency-Track runbook uses the same name, and
.gitignore now ignores .env.bak / *.env.bak (the old patterns stay).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BTHimXjrtArDbsDweyjkYz
@MCheli
MCheli merged commit 924a6f7 into main Nov 25, 2026
3 checks passed
@MCheli
MCheli deleted the session-bus/env-single-backup branch November 25, 2026 15:02
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.

1 participant