Adoptable Cookbooks List

Looking for a cookbook to adopt? You can now see a list of cookbooks available for adoption!
List of Adoptable Cookbooks

Supermarket Belongs to the Community

Supermarket belongs to the community. While Chef has the responsibility to keep it running and be stewards of its functionality, what it does and how it works is driven by the community. The chef/supermarket repository will continue to be where development of the Supermarket application takes place. Come be part of shaping the direction of Supermarket by opening issues and pull requests or by joining us on the Chef Mailing List.

Select Badges

Select Supported Platforms

Select Status


ghubbkup (3) Versions 0.1.59

Installs/Configures ghubbkup

cookbook 'ghubbkup', '= 0.1.59', :supermarket
cookbook 'ghubbkup', '= 0.1.59'
knife supermarket install ghubbkup
knife supermarket download ghubbkup
Quality -%

Travis-ci status: Build Status

ghubbkup Cookbook

ghubbkup is a Ruby cmd-line utility that can be used to backup Git repos on Github using the Github API v3.


  • A working Ruby 1.9.x installation.
  • Installation of s3cmd

Ruby Gem Dependencies


Set config file for ghubbkup.

default['ghubbkup']['conf_dir'] = '/etc'

Set ghubbkup install dir.

default['ghubbkup']['install_dir'] = '/usr/local/bin'

Set Github user. You should probably override this!

default['ghubbkup']['user'] = 'root'

Set group owner of config & backup dir. You should probably override this!

default['ghubbkup']['group'] = 'root'

Set Github password. You should probably override this!

default['ghubbkup']['pass'] = 'secret'

Encrypted data bag secret file.

default['ghubbkup']['data_bag_secret'] = '/etc/chef/encrypted_data_bag_secret'

Encrypted data bag name.

default['ghubbkup']['encrypted_data_bag_name'] = 'ghubbkup'

Encrypted data bag item.

default['ghubbkup']['encrypted_data_bag_item'] = 'creds'

Set tmp repo list.

default['ghubbkup']['tmp_repo_list'] = '/tmp/repos.txt'

Set repo list.

default['ghubbkup']['repo_list'] = '/tmp/repos2.txt'

Set backup directory.

default['ghubbkup']['backup_dir'] = '/tmp/github_repos_backup'

Set git extension.

default['ghubbkup']['git_extension'] = '.git'

Set git URL.

default['ghubbkup']['git_url'] = ''

Backup method. Possible options: s3.

Set to s3 if you wan to backup repos to s3. No backups are done by default.

default['ghubbkup']['backup_type'] = ''

Override this with appropriate s3cmd line options you need.

default['ghubbkup']['s3cmd_cmdline_options'] = 'sync'

You MUST Override this with a file[s]/dir[s] you want to backup to S3!

default['ghubbkup']['files_to_backup'] = ''

You MUST override this with an S3 bucket you want to backup files to!

default['s3_bucket'] = ''


You'll need to create a secret key for your data bag.
skywalker@alderaan:~$ openssl rand -base64 512 > data_bag_secret_key
Create new data bag item to be used with S3.
skywalker@alderaan:~/your/chef-repo$ knife data bag create --secret-file ~/data_bag_secret_key ghubbkup creds
Created data_bag[ghubbkup]
Created data_bag_item[creds]

"id": "creds",
"github_user": "YOUR_GITHUB_USER NAME_HERE",

If you get the following error below...
ERROR: RuntimeError: Please set EDITOR environment variable

...make sure you export your editor as EDITOR
export EDITOR=vim

Verify your encrypted data bag items.
skywaler@alderaan:~/your/chef-repo$ knife data bag show ghubbkup creds
id: creds
cipher: aes-256-cbc
version: 1
cipher: aes-256-cbc
version: 1

Now check your decrypted data bag items
skywaler@alderaan:~/your/chef-repo$ knife data bag show –secret-file=/home/you/data_bag_secret_key ghubbkup creds
id: creds

You may also want to export an encrypted version of your data bag to add to your version control such as Git
skywalker@alderaan:~ knife data bag show ghubbkup creds -Fj > data_bags/ghubbkup/ghubbkup.json

Copy your secret key to your node.
skywalker@alderaan:~ $ scp /home/you/data_bag_secret_key skywalker@alderaan:
skywalker@alderaan's password:
data_bag_secret_key 100% 695 0.7KB/s 00:00


Move your key to /etc/chef
skywalker@alderaan:~ $ sudo mv /home/skywalker/data_bag_secret_key /etc/chef/


  1. By default, ghubbkup will not try to backup your repos anywhere.
  2. You must override default['ghubbkup']['backup_type'] & set to s3.
  3. The only non-local backup method supported is Amazon's S3.
  4. You must also set default['s3_bucket'] to name of the bucket you want to backup files to.
  5. You must also set default['ghubbkup']['files_to_backup'] to the files you'd like to backup.
  6. You must also set default['ghubbkup']['backup_dir'] to the directory you want to backup your repos to.
  7. You can ignore the aforementioned attributes if you don't want to backup to S3 ( just clone all repos locally without copying to S3 ).
  8. You must follow the README in the amazon_s3cmd cookbook to set up encrypted data bag for your S3 credentials.


This cookbook depends on my amazon_s3cmd cookbook which installs the s3cmd.


Below is a sample role you could use:
name "ghubbkup"
description "Install ghubbkup cmd-line tool to backup Github repos."
override_attributes( "amazon_s3cmd" => {
"data_bag_secret" => "/home/skywalker/data_bag_secret",
"encrypted_data_bag_name" => "s3cmd-ghubbkup" },
"ghubbkup" => {
"data_bag_secret" => "/home/skywalker/data_bag_secret",
"group" => "skywalker",
"backup_type" => 's3',
"files_to_backup" => "/mnt/backup/github/*",
"s3_bucket" => "s3://skywalker-github-backup" }
run_list "recipe[ghubbkup]"

Now just include your ghubbkup role in your node's run_list:

"run_list": [

Example ghubbkup commands

Clone ALL repos for a single Github user or org.
skywalker@alderaan:~$ ghubbkup all


  • You should issue ghubbkup commands as the user who has access to your Github account.
  • You can override node['ghubbkup']['git_url'] & set it to to use SSH.
  • Command <code>ghubbkup all</code> will do <code>git clone</code> if repo isn't cloned & <code>git pull</code> if repo is already cloned.


  1. Fork the repository on Github by clicking here.
  2. Create a topic branch (like yourname-add-awesomeness).
  3. Write you change.
  4. Write tests for your change (if applicable).
  5. Run the tests, ensuring they all pass.
  6. Submit a Pull Request using Github here.

License and Authors

Author: Gerald L. Hevener Jr., AKA jackl0phty.

Dependent cookbooks

amazon_s3cmd >= 0.0.0

Contingent cookbooks

There are no cookbooks that are contingent upon this one.

No quality metric results found