#!/bin/bash # Pase B (2/2): descarga los recursos (css/js/img/pdf/mp3...) referenciados por las paginas set -uo pipefail BASE=/home/rafa/joomla-migration/mirror-antiguo RUN=$(cat "$BASE/CURRENT_RUN") DIR=$BASE/runs/$RUN W=${WORKERS:-3} [ -s "$DIR/assets-input.txt" ] || { echo "no hay assets-input.txt"; exit 1; } mkdir -p "$DIR/chunks-assets" "$DIR/logs" rm -f "$DIR/chunks-assets"/*.txt split -n l/$W -d --additional-suffix=.txt "$DIR/assets-input.txt" "$DIR/chunks-assets/a-" date -u +%FT%TZ > "$DIR/logs/passB.start" for c in "$DIR/chunks-assets"/a-*.txt; do n=$(basename "$c" .txt) wget --input-file="$c" \ --force-directories --directory-prefix="$DIR/raw" \ --no-verbose -e robots=off --no-clobber \ --user-agent='feadulta-archiver/1.0 (+incident-183; mirror local)' \ --wait=0.05 --tries=2 --timeout=45 --waitretry=3 \ --output-file="$DIR/logs/wget-$n.log" & done wait date -u +%FT%TZ > "$DIR/logs/passB.end" echo "PASE B TERMINADO" find "$DIR/raw" -type f | wc -l du -sh "$DIR/raw" echo "=== errores ===" grep -hoE 'ERROR [0-9]+' "$DIR/logs"/wget-a-*.log | sort | uniq -c