Skip to content
A python script that will backup all your bitbucket repos locally (both git and mercurial)
Branch: master
Clone or download
Latest commit a02fe87 Jul 16, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
tests add very genreal smoke test Feb 12, 2015
.gitignore python 3 fixes for #36 May 22, 2015
.travis.yml update travis dist Jun 29, 2019
LICENSE.txt add license May 22, 2015
README.md fix readme Jul 16, 2019
backup.py add oauth Jul 16, 2019
bitbucket-backup create bin Feb 12, 2015
requirements.txt add oauth Jul 16, 2019
setup.cfg add setup files Feb 12, 2015
setup.py add oauth Jul 16, 2019

README.md

#Bitbucket backup

Build Status

Description

This python script will backup all of your Bitbucket repos (both mercurial and git) locally. If the repository does not exist locally the repo will be cloned to the <local_backup_location>. If the repo does exist locally an hg pull will be run for mercurial repos, an git remote update will be run for git repos.

Installation

pip install -U https://github.com/samkuehn/bitbucket-backup/archive/master.zip

Quickstart

bitbucket-backup [-u <bitbucket_username>] [-p <bitbucket_password>] [-k <oauth_key>] [-s <oauth_secret>]
  [-l <local_backup_location>] [-t <bitbucket_team>] [-a] [-v] [-q] [-c] [--http] [--skip-password] [--mirror]
  [--prune] [--fetchlfs]

Username/password, are needed to access the Bitbucket api to get a repo listing. At this time it is not used to do the clone/update. Clone/update requires that your ssh keys have been uploaded to Bitbucket.

You can backup a team's repositories instead of your own by supplying the optional -t parameter.

App passwords

If would like, you can use app passwords instead of your password used to login to Bitbucket. The password must have read repositories permission. https://confluence.atlassian.com/bitbucket/app-passwords-828781300.html

OAuth authentication

You can use OAuth authentication if you do not want to use username/password. There are 4 steps to using OAuth.

  1. Create OAuth consumer keys here: https://bitbucket.org/account/user/{username}/api
  2. Make sure that your consumer has the following permissions:
    • Account: Read
    • Projects: Read
    • Repositories: Read
  3. Specify the -k <oauth_key> -s <oauth_secret> flags
  4. Make sure requests-oauthlib is installed pip install requests-oauthlib

Requirements

You do need to have your ssh keys uploaded for the computer that you are running the backup on.

Additional notes

I am hosting this on GitHub because I believe it is superior for public repos (I understand the irony).

You can’t perform that action at this time.