Differences

This shows you the differences between two versions of the page.

Link to this comparison view

backup_script [2013/01/14 22:47] (current)
Line 1: Line 1:
 +**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:
 +  - Copy all scripts to ~/ of you game-server owner.
 +  - Setup execution permissions: chmod +x ~/*.sh
 +  - –°hange scripts to use in your environment. 
 +  - Create folder for backups: "mkdir ~/backup"
 +  - Add cron task: "crontab -e"
 +<code>0 4 * * * ~/backup.sh > /dev/null</code>
 +That task will be executed everyday in 04:00 AM.
 +
 + 
 +
 +====== Files ======
 +You could download them here {{:scripts.tgz|}} or copy from page:
 +
 +start.sh:
 +<code bash>
 +#!/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
 +</code>
 +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:
 +<code bash>
 +#!/bin/sh
 +killall -s SIGINT minetest
 +</code>
 +
 +status.sh:
 +<code bash>
 +#!/bin/sh
 +sockstat | grep 30000
 +</code>
 +
 +backup.sh:
 +<code bash>
 +#!/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
 +</code>
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