Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Simple Minecraft Server Backup Script
cd /home/<user>/Minecraft/mcserver/
# Stop all detached screen sessions with this name
for session in $(screen -ls | grep -o "[0-9]*\.$SESSION_NAME")
echo "Closing Screen: $session"
screen -S "$session" -X stuff "stop $(echo -ne '\r')"
# Zip up the minecraft dir
zip -r "backups/$SESSION_NAME-backup-$(date +"%d-%m-%y_%T").zip" * -x backups/**\*
# Restart the MC server
screen -dmSL "$SESSION_NAME" java -Xms1024M -Xmx1024M -jar minecraft_server.jar nogui
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.