nalc-server/backup.sh
sys4 8eeceb1ac8 Réorganisation du dépôt.
Afin de prendre en compte les nouvelles branches du serveur NALC.
2019-04-22 14:40:36 +02:00

48 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
# Variables à modifier
bdd=nalc-0.4.17
worldname=nalc
servername=nalc-server-0.4.17-r1
serverpath=/home/minetest/$servername
bak=$serverpath/backup
world=$serverpath/minetest/worlds/$worldname
if [[ ! -d $bak ]]; then
mkdir -p $bak
fi
bak_tmp=/var/tmp/$servername
if [[ ! -d $bak_tmp ]]; then
mkdir $bak_tmp
fi
cp $serverpath/minetest/minetest.conf $bak/
cp $serverpath/start.sh $bak/
cp $serverpath/backup.sh $bak/
cp $serverpath/shutdown.sh $bak/
pushd $world
rm -r rollback.sqlite
tar -I pbzip2 -cf $bak/world.tar.bz2 . # <-- requiert pbzip2, à installer avant !
popd
pg_dump -F c -f $bak_tmp/$bdd.dump $bdd
pg_dump -F c -f $bak_tmp/players-$bdd.dump players-$bdd
pushd $bak_tmp
tar --label=SQL_DUMP-$servername -cf $bak/dump_sql.tar --remove-files *.dump
popd
log_dir=$serverpath/logs
[[ ! -d $log_dir ]] && mkdir $log_dir
pushd $log_dir
if [[ -f moredebug.log ]]; then
d=$(date +%Y-%m-%d.%H.%M.%S)
mv moredebug.log moredebug_$d.log
bzip2 moredebug_$d.log
tar --label=LOGS-$servername -rf moredebug-logs.tar --remove-files moredebug*.log.bz2
fi
popd