Utility scripts for a TES3MP server administrator.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

35 lines
1.1 KiB

#!/bin/bash
set -e
set -x
hourly_limit=7
weekly_limit=90
otherlimit=365
playerlimit=365
right_now=$(date +%F)-$(date +%T)
tes3mp_dir=$(realpath $(dirname ${0}))/..
if [ -d ${tes3mp_dir}/../backups/hourly ]; then
echo "Pruning hourly backups older than $hourly_limit days"
find ${tes3mp_dir}/../backups/hourly/ -mindepth 1 -mtime +${hourly_limit} -exec /bin/rm -fv {} \;
fi
if [ -d ${tes3mp_dir}/../backups/weekly ]; then
echo "Pruning weekly backups older than $weekly_limit days"
find ${tes3mp_dir}/../backups/weekly/ -mindepth 1 -mtime +${weekly_limit} -exec /bin/rm -fv {} \;
fi
if [ -d ${tes3mp_dir}/lua/CoreScripts/data/player ]; then
echo "Pruning unused players older than $playerlimit days"
find ${tes3mp_dir}/lua/CoreScripts/data/player/ -mindepth 1 -mtime +${playerlimit} -exec /bin/rm -fv {} \;
fi
if [ -d ${tes3mp_dir}/../backups ]; then
echo "Pruning other backups older than $otherlimit days"
cd ${tes3mp_dir}/../backups
find . -mindepth 1 -path ./hourly -prune -o -path ./weekly -prune -o -mtime +${otherlimit} -exec /bin/rm -fv {} \;
fi
echo ${right_now} PRUNE DONE!