Skip to content

Instantly share code, notes, and snippets.

@comfuture
Created July 29, 2011 06:04
Show Gist options
  • Save comfuture/1113226 to your computer and use it in GitHub Desktop.
Save comfuture/1113226 to your computer and use it in GitHub Desktop.
safe minecraft incremental backup script
#!/bin/sh
# init git repository with "git init" command
# minecraft server is running on screen named "mc"
# ^M means newline character. type c-V-M in your editor
# put this file in your minecraft server's directory
# edit crontab with "crontab -e" and add this line:
# 0 12 * * * /path/to/minecraft/backup.sh > /dev/null 2>&1
CWD=$(readlink -f `dirname $0`)
screen -S mc -X stuff "say [Backup] Server goes readonly in 10 seconds^M"
sleep 10
screen -S mc -X stuff "save-off^M"
screen -S mc -X stuff "save-all^M"
cd $CWD
git add .
git commit -a -m"daily backup"
screen -S mc -X stuff "save-on^M"
screen -S mc -X stuff "say [Backup] Done...^M"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment