SPB Git forge

spb/trouve-ka

Public ★ Pinned

Trouve-KA — moteur de recherche web indépendant, Québec-first. Crawler distribué, index OpenSearch, ranking bilingue, galerie d'images. En prod : www.trouve-ka.com

40commits 1branches 0releases
9.2 MBsize
maindefault branch
23 days agolast push
Python 51.9% TypeScript 32.7% JavaScript 4.8% CSS 4.1% Shell 2.9% HTML 1.8% SQL 1.5%
1.8 KB · 43 lines shellscript
Raw Blame History
1#!/bin/sh2# Trouve-KA — snapshot quotidien OpenSearch (node search M2M32b)3# Author: Simon-Pierre Boucher4# Contact: contact@spboucher.ai5#6# Snapshots natifs OpenSearch (incrémentaux entre eux) dans un dossier hôte7# monté dans le container (path.repo=/mnt/snapshots). Rotation 7 jours.8# Restauration : POST _snapshot/trouveka-fs/<snap>/_restore9#   (index fermé ou renommé via rename_pattern au besoin).1011PATH="$HOME/.local/bin:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"12export PATH13LOG="$HOME/trouveka-backups/backup.log"14STAMP=$(date '+%Y%m%d')15OS=http://localhost:92001617mkdir -p "$HOME/trouveka-backups"18log() { echo "$(date '+%F %T') [os] $*" >> "$LOG"; }1920# Dépôt de snapshots (idempotent)21curl -s -m 20 -X PUT "$OS/_snapshot/trouveka-fs" -H 'Content-Type: application/json' \22  -d '{"type":"fs","settings":{"location":"/mnt/snapshots","compress":true}}' >/dev/null 2>&12324RES=$(curl -s -m 590 -X PUT "$OS/_snapshot/trouveka-fs/daily-$STAMP?wait_for_completion=true" \25  -H 'Content-Type: application/json' \26  -d '{"indices":"trouveka-docs-v2","include_global_state":false}')27case "$RES" in28  *'"state":"SUCCESS"'*) log "snapshot daily-$STAMP OK" ;;29  *already*exists*) log "snapshot daily-$STAMP déjà présent" ;;30  *) log "ÉCHEC snapshot : $(echo "$RES" | head -c 200)"; exit 1 ;;31esac3233# Rotation : supprimer les snapshots > 7 jours (via l'API, jamais le filesystem)34CUTOFF=$(date -v-7d '+%Y%m%d' 2>/dev/null || date -d '7 days ago' '+%Y%m%d')35for snap in $(curl -s -m 30 "$OS/_snapshot/trouveka-fs/_all" | grep -o '"snapshot":"daily-[0-9]*"' | grep -o 'daily-[0-9]*'); do36  d=${snap#daily-}37  if [ "$d" -lt "$CUTOFF" ] 2>/dev/null; then38    curl -s -m 60 -X DELETE "$OS/_snapshot/trouveka-fs/$snap" >/dev/null39    log "rotation : $snap supprimé"40  fi41done42exit 043