Skip to content

Instantly share code, notes, and snippets.

@SharkyRawr
Last active July 26, 2020 22:20
Show Gist options
  • Save SharkyRawr/db099611135fc76499d2 to your computer and use it in GitHub Desktop.
Save SharkyRawr/db099611135fc76499d2 to your computer and use it in GitHub Desktop.
Aprilon Minecraft Server backup script
#!/bin/bash
SESSION="survival"
BACKUPDIR="/home/mc/backups/$SESSION"
WORLDS="world world_nether"
# For debugging
#set -x
#trap read debug
if [ ! -d "$BACKUPDIR" ]; then
mkdir -p "$BACKUPDIR"
fi
screen -S $SESSION -X stuff "say Starting world backup...
"
sleep 2
screen -S $SESSION -X stuff "save-off
"
sleep 5
screen -S $SESSION -X stuff "save-all
"
sleep 15
today=$(date +%Y%m%d_%H%M)
echo Backing up the Aprilon Minecraft world into $BACKUPDIR/world_$today.tar.gz ...
# find world* -name "*.spm" -delete # spout metadata, unused
time tar cfz $BACKUPDIR/world_$today.tar.gz $WORLDS
screen -S $SESSION -X stuff "save-on
"
screen -S $SESSION -X stuff "say Backup done!
"
# ToDo: simple script using find to delete files older than X days
#/home/apn/cleanup_backups.sh
echo Done!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment