Automatically Backup a MongoDB Database to DropBox using Github action

Abu Sadat Md Sayem
2 min readMay 30, 2021

A backup of a database is a way of protecting and restoring the data. We will see how we can take a backup from MongoDB and store the backup to dropbox.

First of all, we shall create a file named in /scripts directory. Then we shall write our shell script to take backup and upload it to DropBox.

Now it’s time to set up GitHub action. We have to create a .gihub/workflows directory in our repository, to set up our GitHub action to automatically backup our database we have to create a .yml file as well. We have created backup.yml


To upload the backup file to DropBox we need an API access token. After going to this URL click the Create apps button

Then check Scoped access, App folder, and input your app name.

After creating the app add permissions and don’t forget to click submit button.

Before generating a token change Access token expiration Short-lived to No expiration.

Copy this access token and MongoDB URI, then add it to GitHub secrets.{username}/{repository}/settings/secrets/actions

Yay! We have done our setup. After pushing to the GitHub default branch, If everything fine we should get the backup on UTC 00:00 or by running this workflow manually from the Actions tab.