Last active
August 29, 2015 14:03
-
-
Save SamuelTurner/071b87d3679fb908f53a to your computer and use it in GitHub Desktop.
Simple Minecraft Server Backup Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
cd /home/<user>/Minecraft/mcserver/ | |
SESSION_NAME='mcserver' | |
# Stop all detached screen sessions with this name | |
for session in $(screen -ls | grep -o "[0-9]*\.$SESSION_NAME") | |
do | |
echo "Closing Screen: $session" | |
screen -S "$session" -X stuff "stop $(echo -ne '\r')" | |
done | |
# 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