#!/usr/bin/env bash # backup-dev-checkpoint.sh - Lightweight local checkpoint (code + manifest) # Saves a tar.gz under /home/michele/netgescon/docs/logs/checkpoints without requiring sudo. set -euo pipefail PROJECT_DIR="/home/michele/netgescon/netgescon-laravel" CHECKPOINT_DIR="/home/michele/netgescon/docs/logs/checkpoints" DATE="$(date +%Y%m%d_%H%M%S)" OUT_BASENAME="netgescon-laravel_checkpoint_${DATE}" OUT_TAR="${CHECKPOINT_DIR}/${OUT_BASENAME}.tar.gz" OUT_MANIFEST="${CHECKPOINT_DIR}/${OUT_BASENAME}.txt" mkdir -p "$CHECKPOINT_DIR" cd "$PROJECT_DIR" GIT_TOPLEVEL="$(git rev-parse --show-toplevel 2>/dev/null || true)" GIT_HEAD="$(git rev-parse --short HEAD 2>/dev/null || true)" GIT_BRANCH="$(git rev-parse --abbrev-ref HEAD 2>/dev/null || true)" GIT_STATUS_SHORT="$(git status -sb 2>/dev/null || true)" # Create tar excluding heavy/derived/sensitive dirs # NOTE: vendor/node_modules may be tracked in this repo, but we still exclude them from the checkpoint to keep size manageable. tar \ --exclude='./vendor' \ --exclude='./node_modules' \ --exclude='./storage' \ --exclude='./public/build' \ --exclude='./public/hot' \ --exclude='./.env' \ --exclude='./.env.*' \ --exclude='./.git' \ -czf "$OUT_TAR" \ -C "$PROJECT_DIR" . TAR_SIZE="$(du -h "$OUT_TAR" | awk '{print $1}')" { echo "NetGescon Laravel - DEV CHECKPOINT" echo "=================================" echo "Date: $(date)" echo "Project: $PROJECT_DIR" echo "Archive: $OUT_TAR (${TAR_SIZE})" echo echo "Git:" echo "- toplevel: ${GIT_TOPLEVEL}" echo "- branch: ${GIT_BRANCH}" echo "- head: ${GIT_HEAD}" echo echo "Git status (short):" echo "$GIT_STATUS_SHORT" echo echo "Recent commits (10):" git --no-pager log -10 --oneline --decorate 2>/dev/null || true echo echo "Notes:" echo "- This checkpoint excludes vendor/, node_modules/, storage/, public/build, public/hot, .env* and .git" echo "- Use it to recover the current working tree quickly if VS Code or the workspace breaks" } > "$OUT_MANIFEST" echo "Checkpoint created: $OUT_TAR" echo "Manifest created: $OUT_MANIFEST"