Files
openwrt/scripts/backup.sh
Dan Head 1c59ca4af4 chore: initial repo setup with baseline config backup
- Pull current config from router (OpenWRT 24.10.2)
- Add backup, safe-apply, and push-all scripts
- Add CLAUDE.md with workflow rules and context
- Add network-map.md with current topology and planned VLANs

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-02 22:22:08 +01:00

30 lines
824 B
Bash
Executable File

#!/usr/bin/env bash
# Pull current router config into config/ and commit if there are changes.
set -euo pipefail
ROUTER="${ROUTER:-openwrt}"
CONFIGS=(dhcp dropbear firewall network system wireless)
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CONFIG_DIR="$SCRIPT_DIR/../config"
echo "Pulling config from $ROUTER..."
for f in "${CONFIGS[@]}"; do
ssh "$ROUTER" "cat /etc/config/$f" > "$CONFIG_DIR/$f"
echo " $f"
done
cd "$SCRIPT_DIR/.."
if git diff --quiet && git diff --cached --quiet; then
echo "No changes — config is up to date."
else
echo ""
git diff --stat config/
echo ""
read -rp "Commit these changes? [y/N] " answer
if [[ "${answer,,}" == "y" ]]; then
git add config/
git commit -m "backup: pull config from router $(date '+%Y-%m-%d %H:%M')"
echo "Committed."
fi
fi