docs: add CLAUDE.md, move backup guide into installer, drop linux-to-sync

- CLAUDE.md: full contributor guide — service template, all helpers,
  globals, DRY_RUN convention, Caddy wiring, non-Docker patterns
- services/backup.sh: print backup strategy guide (Kopia/Borg/rsync/
  rsnapshot + when to use each) at the start of install_backup()
- README.md: remove standalone backup section, fix broken backup row,
  inline base package list, add CLAUDE.md to layout
- services/linux-to-sync.sh: deleted (never worked)
- setup.sh: remove linux-to-sync from is_installed()

https://claude.ai/code/session_019XgsQ13XKm4Zj3cNsDNwHj
This commit is contained in:
Claude
2026-06-04 14:29:02 +00:00
parent b467672a9e
commit 177598a79e
5 changed files with 301 additions and 304 deletions
+62
View File
@@ -25,6 +25,68 @@ register_service backup backup "Automatic encrypted backups (Kopia)"
install_backup() {
log_info "Setting up automatic encrypted backups (Kopia)..."
echo ""
echo "╔═══════════════════════════════════════════════════════════════════╗"
echo "║ BACKUP STRATEGIES — choose the right tool for your data ║"
echo "╚═══════════════════════════════════════════════════════════════════╝"
echo ""
echo " This installer sets up Kopia (the recommended default), but here"
echo " is a quick guide to all available options so you can pick the"
echo " right tool for each type of data."
echo ""
echo " ┌─────────────────────────────────────────────────────────────────┐"
echo " │ KOPIA (installed here) — block-level dedup + zstd + encryption │"
echo " │ Use for: files that change constantly — Minecraft worlds, │"
echo " │ game saves, Steam prefixes, Docker config volumes. │"
echo " │ Changed blocks are stored once; old blocks are shared. │"
echo " │ Restores via: kopia snapshot list / kopia restore │"
echo " └─────────────────────────────────────────────────────────────────┘"
echo ""
echo " ┌─────────────────────────────────────────────────────────────────┐"
echo " │ BORG (sudo apt install borgbackup) — chunk dedup + encryption │"
echo " │ Use for: same as Kopia. Choose Borg if you prefer Borgmatic │"
echo " │ (YAML config), Vorta (GUI), or multi-machine repos. │"
echo " │ borg init / borg create / borg list / borg extract │"
echo " └─────────────────────────────────────────────────────────────────┘"
echo ""
echo " ┌─────────────────────────────────────────────────────────────────┐"
echo " │ RSYNC plain rsync -av --delete /src/ /dest/ │"
echo " │ Use for: media, ROMs, files that rarely change and you just │"
echo " │ need a copy. Fast, transparent — no special restore tool. │"
echo " │ Not suitable for files that change often (one bad --delete │"
echo " │ run immediately destroys the only copy in the destination). │"
echo " └─────────────────────────────────────────────────────────────────┘"
echo ""
echo " ┌─────────────────────────────────────────────────────────────────┐"
echo " │ RSYNC --link-dest versioned snapshots, original folder layout │"
echo " │ Creates dated dirs (2024-01-15/, 2024-01-16/, …). │"
echo " │ Unchanged files are hard-linked — cost no extra disk space. │"
echo " │ Each dated dir is a complete, browsable snapshot of the │"
echo " │ source. Original folder structure preserved (unlike │"
echo " │ rsnapshot). If today's --delete wiped something, yesterday's │"
echo " │ dated dir is untouched. │"
echo " │ Use for: general files where you want versioning + readable │"
echo " │ snapshot dirs without a special restore tool. │"
echo " └─────────────────────────────────────────────────────────────────┘"
echo ""
echo " ┌─────────────────────────────────────────────────────────────────┐"
echo " │ RSNAPSHOT (sudo apt install rsnapshot) — automated rotation │"
echo " │ Wraps rsync with a retention scheme (daily.0, weekly.0, …). │"
echo " │ Hard-links unchanged files like --link-dest, but dirs are │"
echo " │ named by rsnapshot (not your original structure). │"
echo " │ Use for: automated versioning without scripting --link-dest, │"
echo " │ when the rsnapshot naming convention doesn't bother you. │"
echo " └─────────────────────────────────────────────────────────────────┘"
echo ""
echo " Quick reference:"
echo " Constantly-changing data (saves, worlds, configs) → Kopia or Borg"
echo " Media / ROMs (rarely changes, just need a copy) → rsync plain"
echo " Versioned snapshots, keep original folder layout → rsync --link-dest"
echo " Versioned snapshots, want auto rotation scripted → rsnapshot"
echo ""
echo " Continuing with Kopia setup..."
echo ""
# ── Repo-conventional paths ──────────────────────────────────────────────
local BACKUP_DIR="$DOCKER_DIR/backup"
local CONF_FILE="$BACKUP_DIR/backup.conf" # editable settings
-130
View File
@@ -1,130 +0,0 @@
#!/bin/bash
# services/linux-to-sync.sh — Clone the private linux-to-sync repository.
# Part of the modular post-install system (sourced by setup.sh).
#
# Ported from ubuntu-post-install-24.04-crowdsec.sh (# ---- LINUX-TO-SYNC ----).
# Clones outis1one/linux-to-sync to ~/linux-to-sync via SSH or HTTPS+PAT.
# No server/container — this is a personal sync/config repo.
register_service linux-to-sync extras "Personal sync & config scripts (linux-to-sync private repo)"
install_linux-to-sync() {
local SYNC_DIR="$ACTUAL_HOME/linux-to-sync"
if [ "$DRY_RUN" = true ]; then
echo "[DRY-RUN] linux-to-sync would:"
echo " - Clone outis1one/linux-to-sync to $SYNC_DIR"
echo " - Authenticate via SSH key or GitHub Personal Access Token"
return 0
fi
# ── Re-run: already cloned → offer pull ──────────────────────────────────
if [ -d "$SYNC_DIR/.git" ]; then
log_info "linux-to-sync already cloned at $SYNC_DIR"
local DO_PULL=""
prompt_yn "Pull latest changes? (y/n) [y]:" "y" DO_PULL
if [[ ${DO_PULL:-y} =~ ^[Yy]$ ]]; then
if sudo -u "$ACTUAL_USER" git -C "$SYNC_DIR" pull; then
log_success "linux-to-sync updated"
else
log_warning "git pull failed — check connectivity and credentials"
fi
fi
return 0
fi
echo ""
echo " Requires access to github.com/outis1one/linux-to-sync"
echo " Authenticate with ONE of:"
echo " [1] SSH key already added to your GitHub account"
echo " [2] GitHub Personal Access Token (PAT)"
echo ""
local AUTH_METHOD=""
prompt_text "Authentication method [1=SSH, 2=PAT, default: 1]:" "1" AUTH_METHOD
AUTH_METHOD="${AUTH_METHOD:-1}"
if [ "$AUTH_METHOD" = "2" ]; then
echo ""
echo " Create a PAT at: https://github.com/settings/tokens/new"
echo " Select the 'repo' scope for full repository access."
echo ""
local GH_TOKEN=""
prompt_text "GitHub Personal Access Token:" "" GH_TOKEN
if [ -z "$GH_TOKEN" ]; then
log_warning "No token provided — skipping."
return 0
fi
log_info "Cloning via HTTPS + PAT..."
if sudo -u "$ACTUAL_USER" \
git clone "https://$GH_TOKEN@github.com/outis1one/linux-to-sync.git" "$SYNC_DIR"; then
# Remove token from remote URL so it isn't stored in plain text
sudo -u "$ACTUAL_USER" git -C "$SYNC_DIR" remote set-url origin \
"https://github.com/outis1one/linux-to-sync.git"
log_success "linux-to-sync cloned to $SYNC_DIR"
echo " Token stripped from remote URL. For future pulls use:"
echo " git -C $SYNC_DIR pull (will prompt for credentials)"
echo " Or set up a credential helper:"
echo " git config --global credential.helper store"
else
log_error "Clone failed — check your PAT and network, then retry."
return 1
fi
else
# SSH auth — git must run as the actual user to use their SSH keys.
echo ""
echo " Checking for SSH key in $ACTUAL_HOME/.ssh/ ..."
local SSH_KEY_FOUND=false
for _k in id_ed25519 id_rsa id_ecdsa; do
if [ -f "$ACTUAL_HOME/.ssh/$_k" ]; then
log_info " Found: $ACTUAL_HOME/.ssh/$_k"
SSH_KEY_FOUND=true
break
fi
done
if [ "$SSH_KEY_FOUND" = false ]; then
log_warning "No SSH key found in $ACTUAL_HOME/.ssh/"
echo ""
echo " To generate one:"
echo " ssh-keygen -t ed25519 -C 'your@email.com'"
echo " cat $ACTUAL_HOME/.ssh/id_ed25519.pub"
echo " → Add the public key at: github.com/settings/keys"
echo ""
local CONTINUE=""
prompt_yn "Continue anyway (will fail if no key on GitHub)? (y/n) [n]:" "n" CONTINUE
[[ ${CONTINUE:-n} =~ ^[Yy]$ ]] || return 0
fi
log_info "Cloning via SSH (running as $ACTUAL_USER)..."
if sudo -u "$ACTUAL_USER" \
git clone git@github.com:outis1one/linux-to-sync.git "$SYNC_DIR"; then
log_success "linux-to-sync cloned to $SYNC_DIR"
else
log_error "SSH clone failed."
echo ""
echo " Common causes:"
echo " • SSH key not added to GitHub — go to github.com/settings/keys"
echo " • Key not accepted by ssh-agent — try: ssh-add $ACTUAL_HOME/.ssh/id_ed25519"
echo " • Test with: sudo -u $ACTUAL_USER ssh -T git@github.com"
echo " Then retry: sudo ./setup.sh linux-to-sync"
return 1
fi
fi
write_readme "$SYNC_DIR" << MD
# linux-to-sync
Private personal sync and config repository cloned from outis1one/linux-to-sync.
## Update
\`\`\`bash
cd $SYNC_DIR
git pull
\`\`\`
MD
echo ""
echo " Cloned to: $SYNC_DIR"
echo ""
}