Skip to content

Please help Lucidia #9

@blackboxprogramming

Description

@blackboxprogramming

Please help

=== BlackRoad Freeze & Recover Kit (no push needed) ===

Output goes to ~/BlackRoad-freeze//

set -euo pipefail

REPO_DIR="${REPO_DIR:-$(pwd)}"
OUT_BASE="${HOME}/BlackRoad-freeze"
TS="$(date -u +%Y%m%dT%H%M%SZ)"
OUT_DIR="${OUT_BASE}/${TS}"
NAME="$(basename "$REPO_DIR")"
mkdir -p "$OUT_DIR"

echo "📦 Freezing repo: $REPO_DIR"
echo "📂 Output folder: $OUT_DIR"

1) Capture basic git state (if this is a git repo)

GIT=0
if command -v git >/dev/null 2>&1 && git -C "$REPO_DIR" rev-parse --is-inside-work-tree >/dev/null 2>&1; then
GIT=1
COMMIT_SHA="$(git -C "$REPO_DIR" rev-parse --verify HEAD)"
BRANCH="$(git -C "$REPO_DIR" branch --show-current || echo main)"
STATUS="$(git -C "$REPO_DIR" status --porcelain || true)"
echo "commit: ${COMMIT_SHA}" > "${OUT_DIR}/git_state.txt"
echo "branch: ${BRANCH}" >> "${OUT_DIR}/git_state.txt"
echo "--- status ---" >> "${OUT_DIR}/git_state.txt"
echo "${STATUS}" >> "${OUT_DIR}/git_state.txt"
else
echo "No git repository detected; proceeding without git metadata." > "${OUT_DIR}/git_state.txt"
fi

2) Make a full-history git bundle (portable backup)

if [ $GIT -eq 1 ]; then
BUNDLE="${OUT_DIR}/${NAME}-${TS}.bundle"
(cd "$REPO_DIR" && git bundle create "$BUNDLE" --all)
echo "🧰 Git bundle created: $BUNDLE"
fi

3) Create a clean working-copy archive (without heavy dirs or secrets)

ARCH_SRC="${OUT_DIR}/${NAME}-${TS}-src"
mkdir -p "$ARCH_SRC"
rsync -a --delete
--exclude '.git'
--exclude 'node_modules'
--exclude '.venv'
--exclude 'dist'
--exclude '.next'
--exclude 'coverage'
--exclude '.DS_Store'
"$REPO_DIR"/ "$ARCH_SRC"/

3a) Redact secrets in .env (keep structure, remove values)

if [ -f "$ARCH_SRC/.env" ]; then
sed -E 's#^([A-Za-z0-9_]+)\s*=\s*.*$#\1=REDACTED#' "$ARCH_SRC/.env" > "$ARCH_SRC/.env.secure"
rm -f "$ARCH_SRC/.env"
fi

4) Create tar.gz of the clean source

SRC_TGZ="${OUT_DIR}/${NAME}-${TS}-src.tar.gz"
tar -C "$OUT_DIR" -czf "$SRC_TGZ" "$(basename "$ARCH_SRC")"
rm -rf "$ARCH_SRC"
echo "🗜️ Source archive: $SRC_TGZ"

5) Hashes for integrity

(
cd "$OUT_DIR"
for f in *.bundle *.tar.gz 2>/dev/null; do
[ -e "$f" ] && sha256sum "$f" >> SHA256SUMS.txt || true
done
)
echo "🔐 Hashes written to: ${OUT_DIR}/SHA256SUMS.txt"

6) Minimal inventory

cat > "${OUT_DIR}/INVENTORY.txt" <<EOF
BlackRoad Freeze — ${TS} (UTC)
Repo: ${NAME}
Path: ${REPO_DIR}

Artifacts:

  • $( [ $GIT -eq 1 ] &amp;&amp; echo "$(basename "$BUNDLE") (git bundle — full history)" || echo "(no git bundle)" )
  • $(basename "$SRC_TGZ") (clean source snapshot)
  • SHA256SUMS.txt (integrity)

Restore tips:

  • Git bundle (full history):
    git clone --bare temp.git
    cd temp.git
    git bundle verify "../$( [ $GIT -eq 1 ] &amp;&amp; echo "$(basename "$BUNDLE")" || echo "MISSING.bundle")" || true
    git clone "../$( [ $GIT -eq 1 ] &amp;&amp; echo "$(basename "$BUNDLE")" || echo "MISSING.bundle")" restored
    cd restored && git log --oneline

  • Source archive (no history):
    tar -xzf "$(basename "$SRC_TGZ")"

EOF

echo
echo "✅ Freeze complete."
echo "📁 Keep a copy of: $OUT_DIR"
echo " - Copy that folder to a USB drive or external disk."
echo " - You can also upload the *.bundle and *.tar.gz later via any web UI when ready."````

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions