Browse Source

Added backup and prune scripts

modded
parent
commit
c79c56031b
Signed by: hristoast GPG Key ID: 5FC7664AD47AA1C5
  1. 46
      backup.sh
  2. 35
      prune.sh

46
backup.sh

@ -0,0 +1,46 @@
#!/bin/bash
set -e
set -x
_name="${1}"
test -z "${_name}" && _name="tes3mp-backup"
right_now=$(date +%F)-$(date +%T)
tes3mp_dir=$(realpath $(dirname ${0}))/..
backup_dir=${tes3mp_dir}/../backups/${_name}/${right_now}
backup_data_dir=${backup_dir}/CoreScripts/data/custom
backup_data_base_dir=${backup_dir}/CoreScripts/data
backup_player_dir=${backup_dir}/CoreScripts/data/player
backup_world_dir=${backup_dir}/CoreScripts/data/world
corescripts_path=${tes3mp_dir}/lua/CoreScripts
map_path=${corescripts_path}/data/map
player_path=${corescripts_path}/data/player
recordstore_path=${corescripts_path}/data/recordstore
world_path=${corescripts_path}/data/world
real_estate_db=${corescripts_path}/data/custom/RealEstate/RealEstateOwned.json
mkdir -p ${backup_data_dir}/RealEstate ${backup_player_dir} ${backup_world_dir}
rsync -aq ${real_estate_db} ${backup_data_dir}/RealEstate/
rsync -aq ${corescripts_path}/data/custom/__config_*.json ${backup_data_dir}/
rsync -aq ${corescripts_path}/data/custom/__data_*.json ${backup_data_dir}/
rsync -aq ${corescripts_path}/data/custom/factionlist.json ${backup_data_dir}/
rsync -aq ${corescripts_path}/data/custom/ladder_*.json ${backup_data_dir}/
test -d ${map_path} && rsync -aq ${map_path} ${backup_data_base_dir}/
test -f ${player_path}/*.json && rsync -aq ${player_path}/*.json ${backup_player_dir}/
test -d ${recordstore_path} && rsync -aq ${recordstore_path} ${backup_data_base_dir}/
rsync -aq ${world_path}/world.json ${backup_world_dir}/
echo "${right_now} (${_name}) BACKUPS DONE!"

35
prune.sh

@ -0,0 +1,35 @@
#!/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!
Loading…
Cancel
Save