Start/Restart server:
#!/bin/bash
#
# Place script in root of minetest run in place and make executable
#
# The startup command expects world to be in rootfolder/world
# Change as needed/wanted
# here I am setting a time stamp variable which I like to use for logging
TIMESTAMP=`date +%Y%m%d.%H%M`
# Logsbak directory
LOGSBAK=`$HOME/.minetest/logsbak`
# Shutdown any running process
kill $(pidof minetestserver)
# Wait
sleep 10
# Cleanup
tar -cvjf ${LOGSBAK}/logback-${TIMESTAMP}.tar.bz2 debug.txt nohup.out
rm debug.txt nohup.out
# Start the server
nohup ./bin/minetestserver --gameid minetest --world world &
# Wait for it to start
sleep 10
# Renice running process to 10
renice 10 $(pidof minetestserver)
echo "All done"
Backup script:
#!/bin/bash
#
# Place script in root of minetest run in place and make executable
#
# Make sure to make directory for worldbackups and alter any variables as needed
#
# The startup command expects world to be in rootfolder/world
# Change as needed/wanted
#terminate minetestserver
kill $(pidof minetestserver)
# Wait
sleep 10
# Variable for logsback directory
LOGSBAK=`$HOME/.minetest/logsbak`
# here I am setting a time stamp variable which I like to use for logging
TIMESTAMP=`date +%Y%m%d.%H%M`
# here I am setting up the backup directory as a variable
DEST_DIR="$HOME/.minetestworldbackups"
# here I am setting up the directory in which I want to backup, again another variable
SRC_DIR="$HOME/.minetest"
# let's create a variable for the backup file name file
FNAME="minetestbackup"
# let's create a variable for the log file, let's also name the log file with the filename and timestamp it
LOG="$HOME/.minetestworldbackups/$FNAME-$TIMESTAMP.log"
# start the backup, create a log file which will record any messages run by this script
echo -e "Starting backup of minetest $SRC_DIR directory" >> ${LOG}
# compress the directory and files, direct the tar.gz file to your destination directory
tar -vczf ${DEST_DIR}/${FNAME}-${TIMESTAMP}.tar.gz ${SRC_DIR} >> ${LOG}
# end the backup, append to log file created by this script
echo -e "Ending backup of minetest $SRC_DIR" >> ${LOG}
# Cleanup
tar -cvjf ${LOGsBAK}/logback-${TIMESTAMP}.tar.bz2 debug.txt nohup.out
rm debug.txt nohup.out
# Start the server
nohup ./bin/minetestserver --gameid minetest --world world &
# Wait
sleep 10
# Renice running process
renice 10 $(pidof minetestserver)
echo "all done.."