backup: 2026-07-11T07:57:07-05:00

This commit is contained in:
jon
2026-07-11 07:57:07 -05:00
parent 9f4e58ddf2
commit ceaaedd225
+8 -38
View File
@@ -425,9 +425,9 @@ show_help() {
echo " available Show models available to install"
echo " install <name> Pull a model into Nexus"
echo
echo " backup Backup vital Nexus files to router (smart/incremental)"
echo " backup -f, full Full backup of all project files"
echo " restore Restore vital Nexus files from router backup"
echo " backup Backup Nexus to Gitea (git commit + push)"
echo " backup -f, full Backup + snapshot live desktop wiring/notes"
echo " restore Restore Nexus from Gitea (git pull + rebuild)"
echo " restore -f, full Full restore of all project files"
echo
echo " help, -h Show this help message"
@@ -471,52 +471,22 @@ update_nexus() {
# BACKUP / RESTORE COMMANDS
# -----------------------------
ensure_router_reachable() {
echo "Checking router connectivity..."
if ssh -q -o BatchMode=yes -o ConnectTimeout=5 router exit 2>/dev/null; then
echo "Router is reachable."
return 0
fi
# Fallback: bring up the WireGuard tunnel — but only on machines that
# actually have NetworkManager + the wgs_client connection (e.g. the roaming
# NexusOS laptop). On a directly-wired desktop or under WSL, nmcli/NM isn't
# usable, so skip the VPN step instead of dying with "permission denied".
if command -v nmcli >/dev/null 2>&1 && \
nmcli -t -f NAME connection show 2>/dev/null | grep -qx wgs_client; then
echo "Router unreachable. Activating WireGuard (wgs_client)..."
if nmcli connection up wgs_client; then
echo "Waiting for VPN to establish..."
sleep 5
if ssh -q -o BatchMode=yes -o ConnectTimeout=10 router exit 2>/dev/null; then
echo "Router reachable via VPN."
return 0
fi
fi
echo "Router still unreachable after VPN activation."
else
echo "Router unreachable, and no WireGuard fallback on this machine."
echo "Expected a direct LAN link to the server — check the 'router' SSH host and the connection."
fi
return 1
}
# Backup/restore go through git → Gitea now (see bin/backup.sh, bin/restore.sh),
# not rsync-to-router, so no SSH/WireGuard reachability gate is needed — git
# handles its own connectivity and errors over HTTPS.
backup_nexus() {
ensure_router_reachable || return 1
echo "Backing up Nexus to router..."
bash "$NEXUS_ROOT/bin/backup.sh"
}
backup_nexus_full() {
ensure_router_reachable || return 1
echo "Full backup of Nexus to router..."
bash "$NEXUS_ROOT/bin/backup.sh" full
}
restore_nexus() {
local mode="$1"
ensure_router_reachable || return 1
echo "WARNING: This will overwrite local files with the remote backup."
echo "This pulls the latest backup from Gitea and rebuilds the environment"
echo "(venv, npm, theme, panel). Local commits must be pushed or stashed first."
printf "Continue? [y/N] "
read -r confirm
if [[ "$confirm" != "y" && "$confirm" != "Y" ]]; then