Achievements

Arctic Code Vault Contributor
IPv6 Certification Badge for Robert Whitney


This page has been visited an unknown number of times.
Page last generated:
2026/03/13 13:44:07.

This Bash script will back your server up to S3: Back your server up remotely with S3 storage

  I wanted to share an alternative script to backup Minecraft servers to S3 storage.
This script is designed to be run on a schedule (e.g., via cron) and will create a backup of the Minecraft server world and upload it to an S3 bucket. It can also be run manually whenever you want to create a backup or, if you are running bukkit/spigot/paper, it can be triggered via the /restart command, which will run the script before restarting the server.

  This script is written in bash and uses the AWS CLI to interact with S3. It creates a compressed archive of the Minecraft world directory and uploads it to the specified S3 bucket with a timestamped filename. The script also includes error handling to ensure that any issues during the backup process are logged appropriately. It should be compatible with most Linux distributions and can be easily modified to fit specific server configurations or backup requirements.

  Make sure that you have the necessary permissions and credentials set up for the AWS CLI to access your S3 bucket, and that you have sufficient storage space in your S3 bucket for the backups.
Be sure to test the script in a safe environment before deploying it on a production server to ensure that it works as expected and does not cause any disruptions to your Minecraft server.

  Also consider implementing a retention policy for your backups to manage storage costs and ensure that you do not run out of space in your S3 bucket over time.
Do not forget to edit the configuration variables at the top of the script to match your specific setup, such as the path to your Minecraft server world, the name of your S3 bucket, and any other relevant settings.

While writing the script I had saved it to /usr/local/bin/mc-backup.sh which allows me to run it from anywhere on the server without needing to specify the full path. I also made sure to give it executable permissions using chmod +x /usr/local/bin/mc-backup.sh.
You can execute the command manually by running mc-backup.sh in the terminal, or you can set up a cron job to run it automatically at regular intervals (e.g., daily, weekly). For example, to run the backup script every day at 2 AM, you could add the following line to your crontab file using crontab -e:

0 2 * * * /usr/local/bin/mc-backup.sh

It's important to note that this script will only work if your Minecraft server is running in a tmux session named "minecraft".
For example:

tmux new -s minecraft
# then inside tmux:
java -Xms4G -Xmx8G ... -jar paper.jar nogui


undefined