This page has been visited an unknown number of times.
Page last generated:
2026/03/13 13:44:07.
This post was written 2026-03-13 04:20:00 -0700 by Robert Whitney and has been viewed an unknown number of times since unknown time. This post was last viewed an unknown length of time ago.
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
xnite, real name Robert Whitney, is a self-taught computer programmer with a passion for technology. His primary focus is on secure, reliable, and efficient software development that scales to meet the needs of the modern web. Robert has been writing since 2010 and has had contributions published in magazines such as 2600: The Hacker Quarterly. His background in technology & information security allows him to bring a unique perspective to his writing. Robert's work has also been cited in scientific reports, such as "Future Casting Influence Capability in Online Social Networks: Fake Accounts and the Evolution of the Shadow Economy" by Matthew Duncan, DRDC Toronto Research Centre.
For Minecraft related inquiries feel free to reach out to the community on the Break Blocks Club discord server, for everything else please email me at admin@xnite.me
You can also find me on the various social media platforms listed on my website, but I do not check them often.