-
-
Save jogerj/87ca68ad79b7dc5800cd810056c25721 to your computer and use it in GitHub Desktop.
RCON bash script to backup minecraft server directory
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 | |
MCRCON_PATH="/usr/local/bin" | |
BACKUP_PATH="/home/opc/mc_backup" | |
MC_PATH="/home/opc/minecraft" | |
IP="127.0.0.1" | |
PORT="25575" | |
PASS="[password]" | |
function rcon { | |
$MCRCON_PATH/mcrcon -H $IP -P $PORT -p $PASS "$1" | |
} | |
rcon "save-off" | |
rcon "save-all" | |
tar -cvpzf $BACKUP_PATH/server-$(date +%F_%R).tar.gz $MC_PATH | |
rcon "save-on" | |
## Delete older backups | |
find $BACKUP_PATH -type f -mtime +7 -name '*.gz' -delete | |
##file paths and other details omitted for this public copy, just replace them with your information if you want to use this | |
##i have this set up on crontab to run every 6 hours | |
##enjoy :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Moved to https://github.com/jogerj/minecraft-scripts