This tutorial is going to show you how to use crontab to backup your Mincraft server data to Dropbox automatically.
If you would like to see how to setup a minecraft server on Raspberry Pi 4, you can go to part 1 here.
Create a Dropbox account first.
Then create a Dropbox app from the link below
You need to get the access token and update permission settings after you created the app.
Select “No expiration” for Access toke expiration and click “Generate” to generate the access token for you app.
Save your access token to somewhere, we need it later
Switch to permission tab
Then check “files.metadata.write” and “files.content.write”.
Click submit to save all changes.
Create Cron Job to upload Minecraft server data periodically
Log on to Portainer we created in part 1.
Click Volume —> Console icon —> Connect
You can access your Minecraft server’s container now.
Open text editor and create file “auto_minecraft_backup.sh”.
Copy these commands to the text editor and you have to replace the access token to yours.
Please also note that you need to keep “Bearer “ in Authorization
Press Control + x, then enter “Y” to save the script file.
You can test the script with the command below:
If you can see the backup in your Dropbox, you can create a cron job to schedule run this script.
Insert this line to config file
It means run the script every day at 5 a.m.
The link below can help you to setup your own schedule for cron job.
Press Control + x, then enter “Y” to save your setting.