I will show how to upload files to Dropbox from Python code.
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.
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 https://www.dropbox.com/developers/apps/ 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 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 http://buklijas.info/blog/2017/12/01/automatic-backup-of-git-repositories-to-dropbox-with-python/
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 buklijas.info on December 1, 2017.