Automatic backup of git repositories to Dropbox with Python by@buklijas.sasa

Automatic backup of git repositories to Dropbox with Python

Sasa Buklijas HackerNoon profile picture

Sasa Buklijas

Electro Technical Officer


I will show how to upload files to Dropbox from Python code.

Why do I need this?

Currently, I am only using WebFaction for all my web services and also as my private git server.

I wanted to make an automatic backup of my git repositories to Dropbox.

Dropbox App

I order to upload files to Dropbox you need to have an access token.

And for the access token, you need to register your app on DBX platform.

All of this must be done on Dropbox website.

The first step is to go to and press “Create App” button.

Step 1

Just click “Create app” button

Step 2

We will use Dropbox API.

We will choose “App folder” because we will just upload one backup to Dropbox, we do not need full access to all our files.

Name your app and click “Create App” button.

Step 3

We will use defaults settings, here we will get the access token so, click “Generate access token” button.

Step 4

Now you have your access token, you will need it in your code, so copy it.

Step 5

Now we have our “my_git_backup” Dropbox app.

pip install

pip install dropbox
pip install fabric

It is always recommended to use virtual environments inside python.

At least I use them always.


For code sample please go to

How I run this automatically

I personally run this command from crontab once per day.
 35 02 * * * /home/user_name/code/venv/bin/fab -f /home/user_name/code/fabfile git_backup_to_dropbox


This can be used for backup of any folder as zip file automaticaly to Dropbox.

For any questions, please write them in comments.

Originally published at on December 1, 2017.