#!/bin/bash # Pase D (corregido): /anterior por INVENTARIO, no por recursion. # # La recursion sobre /anterior funcionaba, pero se estaba comiendo el tiempo en 404: la web antigua # esta llena de enlaces rotos (imagenes de los `_archivos/` de exportaciones de Word que ya no # existen). Iban 3.050 aciertos por 2.744 fallos. Misma leccion del post-mortem: acotar por # inventario. Aqui el inventario es el listado de ficheros del snapshot restaurado — solo la LISTA # DE RUTAS, igual que se hace con la BD; el contenido se sigue capturando por HTTP. set -uo pipefail BASE=/home/rafa/joomla-migration/mirror-antiguo RUN=$(cat "$BASE/CURRENT_RUN") D=$BASE/runs/$RUN SRC=$BASE/restore/web/anterior W=${WORKERS:-4} pkill -f 'antiguo.feadulta.com/anterior/$' && echo "recursion detenida" || echo "recursion ya parada" sleep 2 cd "$BASE/restore/web" find anterior -type f ! -iname '*.php' -printf '%p\n' \ | sed 's#^#http://antiguo.feadulta.com/#' \ | sort -u > "$D/anterior-input.txt" echo "inventario de /anterior: $(wc -l < "$D/anterior-input.txt") ficheros (excluidos los .php)" echo "php excluidos: $(find anterior -type f -iname '*.php' | wc -l)" mkdir -p "$D/chunks-d"; rm -f "$D/chunks-d"/*.txt split -n l/$W -d --additional-suffix=.txt "$D/anterior-input.txt" "$D/chunks-d/d-" date -u +%FT%TZ > "$D/logs/passD2.start" for c in "$D/chunks-d"/d-*.txt; do b=$(basename "$c" .txt) wget --input-file="$c" \ --force-directories --directory-prefix="$D/raw" \ --no-verbose --no-clobber -e robots=off \ --user-agent='feadulta-archiver/1.0 (+incident-183; mirror local)' \ --wait=0.02 --tries=2 --timeout=45 --waitretry=3 \ --output-file="$D/logs/wget-$b.log" & done wait date -u +%FT%TZ > "$D/logs/passD2.end" echo "PASE D TERMINADO" echo "ficheros bajo /anterior: $(find "$D/raw/antiguo.feadulta.com/anterior" -type f | wc -l)" du -sh "$D/raw/antiguo.feadulta.com/anterior" grep -hoE 'ERROR [0-9]+' "$D/logs"/wget-d-*.log | sort | uniq -c