Skip to content

Instantly share code, notes, and snippets.

@renamedquery
Created June 27, 2020 23:27
Show Gist options
  • Save renamedquery/a83a303f1016e317a1cf2fedc8b5a2a6 to your computer and use it in GitHub Desktop.
Save renamedquery/a83a303f1016e317a1cf2fedc8b5a2a6 to your computer and use it in GitHub Desktop.
#!/bin/bash
function rcon {
[PATH_TO_TOOLS_DIR]/mcrcon -H 127.0.0.1 -P [RCON_PORT] -p [RCON_PASSWORD] "$1"
}
rcon "save-off"
rcon "save-all"
tar -cvpzf [PATH_TO_BACKUP_DIR]/server-$(date +%F_%R).tar.gz [PATH_TO_MINECRAFT_SERVER_DIR]
rcon "save-on"
## Delete older backups
[PATH_TO_BACKUP_DIR] -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