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.
Prepare Dropbox
Create a Dropbox account first.
Then create a Dropbox app from the link below
![Screenshot 2020-11-26 at 10.50.27 PM](https://techhkg.com/wp-content/uploads/2020/11/Screenshot-2020-11-26-at-10.50.27-PM.png)
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.
![Screenshot 2020-11-26 at 10.53.15 PM](https://techhkg.com/wp-content/uploads/2020/11/Screenshot-2020-11-26-at-10.53.15-PM.png)
Save your access token to somewhere, we need it later
![Screenshot 2020-11-26 at 11.03.04 PM](https://techhkg.com/wp-content/uploads/2020/11/Screenshot-2020-11-26-at-11.03.04-PM.png)
Switch to permission tab
Then check “files.metadata.write” and “files.content.write”.
![Screenshot 2020-11-26 at 11.06.53 PM](https://techhkg.com/wp-content/uploads/2020/11/Screenshot-2020-11-26-at-11.06.53-PM.png)
Click submit to save all changes.
![Screenshot 2020-11-26 at 11.09.08 PM](https://techhkg.com/wp-content/uploads/2020/11/Screenshot-2020-11-26-at-11.09.08-PM.png)
Create Cron Job to upload Minecraft server data periodically
Log on to Portainer we created in part 1.
![Screenshot 2020-11-26 at 11.20.04 PM](https://techhkg.com/wp-content/uploads/2020/11/Screenshot-2020-11-26-at-11.20.04-PM.png)
Click Volume —> Console icon —> Connect
![Screenshot 2020-11-26 at 11.22.56 PM](https://techhkg.com/wp-content/uploads/2020/11/Screenshot-2020-11-26-at-11.22.56-PM.png)
You can access your Minecraft server’s container now.
![Screenshot 2020-11-26 at 11.41.02 PM](https://techhkg.com/wp-content/uploads/2020/11/Screenshot-2020-11-26-at-11.41.02-PM.png)
Install zip tool
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.
![Screenshot 2020-11-26 at 11.57.32 PM](https://techhkg.com/wp-content/uploads/2020/11/Screenshot-2020-11-26-at-11.57.32-PM.png)
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.
![Screenshot 2020-11-27 at 12.30.07 AM](https://techhkg.com/wp-content/uploads/2020/11/Screenshot-2020-11-27-at-12.30.07-AM.png)
Open crontab config file
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.
https://crontab.guru/
![Screenshot 2020-11-27 at 1.00.10 AM](https://techhkg.com/wp-content/uploads/2020/11/Screenshot-2020-11-27-at-1.00.10-AM.png)
Press Control + x, then enter “Y” to save your setting.
Done!
Leave A Comment