Files
xamxam/deploy/xamxam-logrotate
T

54 lines
1.5 KiB
Plaintext

# XAMXAM — log rotation for application, nginx, and cron logs.
# Installed to /etc/logrotate.d/xamxam (run via `just deploy-logrotate`).
#
# Covers three roots:
# /var/log/xamxam/ app channels (xamxam-app/admin/error/audit-*.log)
# /var/log/nginx/xamxam-nginx-* nginx access + error logs
# /var/log/xamxam-backup-*.log SQLite backup cron
# /var/log/xamxam-cleanup-*.log draft cleanup cron
#
# The app channels additionally self-rotate via Monolog (RotatingFileHandler,
# 30 days) — logrotate here mainly compresses/prunes the nginx and cron files
# and any stragglers. Retention is aligned with the app's 30-day default.
/var/log/xamxam/*.log {
daily
rotate 30
compress
delaycompress
missingok
notifempty
create 664 www-data xamxam
su www-data xamxam
}
/var/log/nginx/xamxam-nginx-access.log /var/log/nginx/xamxam-nginx-error.log {
daily
rotate 52
compress
delaycompress
missingok
notifempty
create 640 root adm
su root adm
sharedscripts
postrotate
if command -v systemctl >/dev/null 2>&1 && systemctl is-active nginx >/dev/null 2>&1; then
systemctl reload nginx >/dev/null 2>&1 || true
elif [ -x /usr/sbin/nginx ]; then
/usr/sbin/nginx -s reopen 2>/dev/null || true
fi
endscript
}
/var/log/xamxam-backup-*.log /var/log/xamxam-cleanup-*.log {
daily
rotate 30
compress
delaycompress
missingok
notifempty
create 644 www-data www-data
su www-data www-data
}