Script for automatic backup copy of the all repositories available to the script (based on OAuth permissions).
- Python
requests
library - Python 2.7+
- git 1.6.5+
This is required to grant read access for script to your repositories.
- Log in to bitbucket using account you want to back up
- Go to Bitbucket settings (in your profile)
- In Access Management choose OAuth configuration page
- Click Add Consumer and fill the form
- Any name, example: Bitbucket Sync
- Callback URL can be any url, since we are not using OAuth authorization based on code exchange
- Check This is a private consumer
- Required permissions are: Account.Read, Team membership.Read, Projects.Read, Repositories.Read
- Click Save and go back to OAuth configuration page
- Click on your new consumer and you will see Key and Secret credentials, remember them, we will need them to start the script. That's it!
You can set up requests
library manually, using pip install requests
command.
If you system uses virtualenv
, then you can create your virtual environment and target pip to requirements.txt
file:
cd path_where_you_store_virtual_env
virtualenv bitbucket_sync_virtualenv
source bitbucket_sync_virtualenv/bin/activate
cd path/to/bitbucket_sync/
pip install -r ./requirements.txt
Make sure that when you run the script the virtualenv is activated.
python bitbucket_sync.py "/home/user/projects_backup" OauthKey oAutHsEcrEt