pull-logs.sh.j2 (1058B)
1 #!/bin/sh 2 # Pulls learningunix.net server logs down to this workstation. 3 # This machine is the rsync destination only — never writes back to the server. 4 set -e 5 6 mkdir -p "{{ log_sync_local_dest }}" 7 8 {% for path in log_sync_remote_paths %} 9 rsync -az -e "ssh -i {{ log_sync_ssh_key }} -o StrictHostKeyChecking=accept-new" \ 10 "{{ log_sync_remote_user }}@{{ log_sync_remote_host }}:{{ path }}" \ 11 "{{ log_sync_local_dest }}/" 12 {% endfor %} 13 14 # Regenerate the goaccess report from all available nginx access logs (current + rotated). 15 # Normalized through zcat -f first: this goaccess build doesn't decompress .gz itself, 16 # and zcat -f transparently handles both compressed and plain files. 17 if command -v goaccess >/dev/null 2>&1; then 18 zcat -f {{ log_sync_local_dest }}/access.log* > {{ log_sync_local_dest }}/.combined-access.log 2>/dev/null 19 goaccess {{ log_sync_local_dest }}/.combined-access.log \ 20 --log-format=COMBINED \ 21 -o {{ log_sync_local_dest }}/report.html \ 22 2>/dev/null || true 23 rm -f {{ log_sync_local_dest }}/.combined-access.log 24 fi