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

  1. #!/bin/bash
  2. set -e
  3. set -x
  4. hourly_limit=7
  5. weekly_limit=90
  6. otherlimit=365
  7. playerlimit=365
  8. right_now=$(date +%F)-$(date +%T)
  9. tes3mp_dir=$(realpath $(dirname ${0}))/..
  10. if [ -d ${tes3mp_dir}/../backups/hourly ]; then
  11. echo "Pruning hourly backups older than $hourly_limit days"
  12. find ${tes3mp_dir}/../backups/hourly/ -mindepth 1 -mtime +${hourly_limit} -exec /bin/rm -fv {} \;
  13. fi
  14. if [ -d ${tes3mp_dir}/../backups/weekly ]; then
  15. echo "Pruning weekly backups older than $weekly_limit days"
  16. find ${tes3mp_dir}/../backups/weekly/ -mindepth 1 -mtime +${weekly_limit} -exec /bin/rm -fv {} \;
  17. fi
  18. if [ -d ${tes3mp_dir}/lua/CoreScripts/data/player ]; then
  19. echo "Pruning unused players older than $playerlimit days"
  20. find ${tes3mp_dir}/lua/CoreScripts/data/player/ -mindepth 1 -mtime +${playerlimit} -exec /bin/rm -fv {} \;
  21. fi
  22. if [ -d ${tes3mp_dir}/../backups ]; then
  23. echo "Pruning other backups older than $otherlimit days"
  24. cd ${tes3mp_dir}/../backups
  25. find . -mindepth 1 -path ./hourly -prune -o -path ./weekly -prune -o -mtime +${otherlimit} -exec /bin/rm -fv {} \;
  26. fi
  27. echo ${right_now} PRUNE DONE!