Latest news about Bitcoin and all cryptocurrencies. Your daily crypto news habit.
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 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 installpip install dropboxpip install fabric
It is always recommended to use virtual environments inside python.
At least I use them always.
Code
For code sample please go to http://buklijas.info/blog/2017/12/01/automatic-backup-of-git-repositories-to-dropbox-with-python/
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
Conclusion
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.
Automatic backup of git repositories to Dropbox with Python was originally published in Hacker Noon on Medium, where people are continuing the conversation by highlighting and responding to this story.
Disclaimer
The views and opinions expressed in this article are solely those of the authors and do not reflect the views of Bitcoin Insider. Every investment and trading move involves risk - this is especially true for cryptocurrencies given their volatility. We strongly advise our readers to conduct their own research when making a decision.