WARNING! LOL RUnglish here LOL

This is my backup scripts for minetest server. HDD and hardware which i used for minetest server is very old, so I chose to make daily backups.

I used specific user to run server and also I use default 30000 port, so scripts writed for this stricture.

Installation

Step by step:

  1. Copy all scripts to ~/ of you game-server owner.
  2. Setup execution permissions: chmod +x ~/*.sh
  3. Сhange scripts to use in your environment.
  4. Create folder for backups: “mkdir ~/backup”
  5. Add cron task: “crontab -e”
0 4 * * * ~/backup.sh > /dev/null

That task will be executed everyday in 04:00 AM.

Files

You could download them here scripts.tgz or copy from page:

start.sh:

#!/bin/sh
minetest --server --config /home/minetest/mineserver.conf > /home/minetest/server.log 2>&1 &
sleep 5
 
pid=`sockstat | grep 30000 | awk '{ print $3 }'`
#sudo renice -n -4 $pid > /dev/null

I used renice to improve responsiveness of my game server, so you shouldn't use it if you run server on fast hardware.

stop.sh:

#!/bin/sh
killall -s SIGINT minetest

status.sh:

#!/bin/sh
sockstat | grep 30000

backup.sh:

#!/bin/sh
 
## Config
dir="/home/minetest"
time=`date +%Y%m%d-%H%M%S`
backupdir=$dir"/backup/"$time
 
 
## Stop game server
echo Server stoped `date` >> $dir/backup/full.log
$dir/stop.sh
 
 
## Backup data
echo Backup Started `date` >> $dir/backup/full.log
 
mkdir $backupdir
# Dump whole world
tar -czf $backupdir/server.tar.gz $dir/.minetest
# Move & compress debug.txt
mv $dir/debug.txt $backupdir
gzip $backupdir/debug.txt
# Move & compress server.log
mv $dir/server.log $backupdir
gzip $backupdir/server.log
# Copy & compress config
cp $dir/mineserver.conf $backupdir
gzip $backupdir/mineserver.conf
 
echo Backup Completed `date` >> $dir/backup/full.log
 
 
## Run game server
echo Server started `date` >> $dir/backup/full.log
$dir/start.sh
backup_script.txt · Last modified: 2013/01/14 22:47 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki