infra: full IaC state after hf-pdocker-01 rebuild (2026-03-08)
Replaces initial Nomad/Consul/Terraform skeleton with current Docker-based infrastructure across all three nodes (hf-pdocker-01, hf-pdocker-02, bart). Key changes: - CLAUDE.md: updated service distribution reflecting hf-pdocker-01 restored - docs/plans/2026-03-08-hf-pdocker-01-rebuild.md: new rebuild plan doc - compose/bart/: ai-agents, guacamole, matrix, media, openvas, smarthome, watchtower - compose/hf-pdocker-02/: traefik, monitoring, adguard, gitea, semaphore, wikijs, unifi, vaultwarden, actual-budget, mcpo, netclaw, trivy, watchtower, n8n - compose/hf-pdocker-01/: frigate, frigate-notify, farm-agent - stacks/: all Swarm stack definitions (monitoring, traefik, smarthome, matrix, guacamole, media, ai-agents, frigate, gitea, semaphore, wikijs, unifi, etc.) - .gitignore: exclude .env credential files and acme.json certs - .env.example: placeholder credential files for all services - .claude/agents/: gitea-backup and other infrastructure agent configs - scripts/: frigate media cleanup and NAS sync scripts Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
#!/bin/bash
|
||||
# =============================================================================
|
||||
# Frigate Media Cleanup
|
||||
# Removes recordings, clips, and snapshots older than 90 days from NAS
|
||||
# Run via cron: 0 3 * * 0 /mnt/docker-data/scripts/cleanup-frigate-media.sh
|
||||
# =============================================================================
|
||||
|
||||
MEDIA_DIR="/mnt/docker-data/media/frigate"
|
||||
MAX_AGE_DAYS=90
|
||||
LOG_FILE="/var/log/frigate-cleanup.log"
|
||||
DRY_RUN=false
|
||||
|
||||
if [ "$1" = "--dry-run" ]; then
|
||||
DRY_RUN=true
|
||||
fi
|
||||
|
||||
log() {
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') $1" | tee -a "$LOG_FILE"
|
||||
}
|
||||
|
||||
if [ ! -d "$MEDIA_DIR" ]; then
|
||||
log "ERROR: $MEDIA_DIR does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log "=== Frigate media cleanup started (max age: ${MAX_AGE_DAYS} days, dry_run: ${DRY_RUN}) ==="
|
||||
|
||||
# Get size before cleanup
|
||||
SIZE_BEFORE=$(du -sh "$MEDIA_DIR" 2>/dev/null | cut -f1)
|
||||
log "Size before: $SIZE_BEFORE"
|
||||
|
||||
# Find and remove old files in recordings/, clips/, exports/
|
||||
for subdir in recordings clips exports; do
|
||||
DIR="$MEDIA_DIR/$subdir"
|
||||
if [ -d "$DIR" ]; then
|
||||
COUNT=$(find "$DIR" -type f -mtime +${MAX_AGE_DAYS} | wc -l)
|
||||
log "Found $COUNT files older than ${MAX_AGE_DAYS} days in $subdir/"
|
||||
if [ "$DRY_RUN" = true ]; then
|
||||
find "$DIR" -type f -mtime +${MAX_AGE_DAYS} -print | head -20
|
||||
log "(dry run - no files deleted)"
|
||||
else
|
||||
find "$DIR" -type f -mtime +${MAX_AGE_DAYS} -delete
|
||||
# Remove empty directories left behind
|
||||
find "$DIR" -type d -empty -delete 2>/dev/null
|
||||
log "Cleaned $subdir/"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# Get size after cleanup
|
||||
SIZE_AFTER=$(du -sh "$MEDIA_DIR" 2>/dev/null | cut -f1)
|
||||
log "Size after: $SIZE_AFTER"
|
||||
log "=== Cleanup complete ==="
|
||||
Reference in New Issue
Block a user