Being mildly paranoid about my data I sometimes worry what would happen to my repositories and gists on GitHub and BitBucket (mid way through drafting this post GitHub went down. Just because you’re paranoid doesn’t mean they’re not after you!). Luckily both these services provide an API to expose these repositories. Using this API I’ve wrote a simple PHP script to go off and clone the repositories from each of these services.
https://github.com/JimMackin/RepoBackup
Ironically this is hosted on GitHub itself.
Install
First grab a copy via github:
git clone https://github.com/JimMackin/RepoBackup.git
Grab any dependencies (you’ll need a copy of composer):
composer install
Use
Run the script and follow the prompts. You will need your GitHub username, GitHub API token and your BitBucket Username and password.
php Repobackup.php
Your repositories will be stored in a Backups
folder split by site and username.