#!/bin/sh # Nightly backup (cron 04:30, see install-cron.sh): settings, secrets, configs, stats and the # kill tally into backups/cs16-YYYY-MM-DD.tar.gz, kept 14 days. Game files are not included # (./setup.sh downloads them again). Also saves the kill tally and prunes logs older than 30 days. . "$(dirname "$0")/env.sh" set -e cd "$D" umask 077 mkdir -p backups C=hlds/cstrike # keep only paths that exist (a fresh install has no stats yet) LIST= for p in .env secrets kills-tally.json $C/mapcycle.txt $C/custom.cfg $C/reunion.cfg \ $C/addons/amxmodx/configs $C/addons/amxmodx/data $C/gungame.stats $C/gungame.streaks \ $C/addons/yapb/conf; do [ -e "$p" ] && LIST="$LIST $p" done tar czf "backups/cs16-$(date +%F).tar.gz" $LIST find backups -name "cs16-*.tar.gz" -mtime +14 -delete # count the kills in the logs before old logs go away python3 kills > /dev/null || true find $C/logs $C/addons/amxmodx/logs -name "*.log" -mtime +30 -delete 2>/dev/null || true echo "$(date '+%F %T') backup ok"