Post

SpaceSMP Minecraft Backup System!

Would you like to know how to backup your Minecraft Server, in a way that follows the 3-2-1 backup technique?

The setup for this is really simple, all that is needed is:

  • Syncthing setup on 2 devices. I recommend the docker container
  • A Minecraft Server
  • Thats it!
    Cost: Provided you already pay for a vps for your Minecraft server, you will only need one other device.
  1. SSH into your server device
  2. Open a new file in your home folder called backup.sh

    1
    
     sudo nano ~/backup.sh
    
  3. Put the following code inside the file

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    
     SRC="Youre Minecraft Server Directory"
     DEST="Your Syncthing Source Directory"
    
     mkdir -p "$DEST"
    
     NEW_BACKUP="$DEST/world-$(date +%Y%m%d-%H%M%S)"
    
     rsync -avh --progress --exclude='bluemap/' "$SRC" "$NEW_BACKUP/"
    
     cd "$DEST" || exit
     ls -1dt world-* | tail -n +3 | xargs -r rm -rf
    

    This script copies your Minecraft Server Directory to your syncthing directory.

  4. Open your cron file by running

    1
    
     crontab -e
    

    Then add this line at the bottom:

    1
    
     0 1 * * * /bin/bash ~/backup.sh
    
  5. In your server’s management panel, set the server to run the command save-all 2 minutes before 1am.
  6. Inside syncthing, setup syncing to your other server.
  7. You’re done! Your server will now backup at 1am every day.

Thank you for reading ;)

Credits: DidiDidi129, eatyourgory

This post is licensed under CC BY 4.0 by the author.