Git Storage

From version 0.4 you can configure Brahin to store your data in a Git repository and synchronise it to GitHub or other remote repository.

Setup

This guide assumes you have installed Brahin with Dokku and that you want to sync your data to GitHub.

Preparation

Create a repo on GitHub.

Create a Personal access token on GitHub.

Generate a secret token for the webhook.

Configuration

Set the following environment variables:

  • STORAGE=git

  • GIT_SYNC_REMOTE=https://myuser:mypersonaltoken@github.com/myuser/myrepo

  • GITHUB_WEBHOOK_SECRET – your secret webhook token (if you're not using GitHub, leave this blank; in which case the webhook won't be authenticated)

To set the environment variables with Dokku:

dokku config:set myapp STORAGE=git GIT_SYNC_REMOTE=... GITHUB_WEBHOOK_SECRET=...

Upgrade and deploy

If you're upgrading from a pre-0.4 version, pull the updated code of Brahin and deploy the app (from your local machine):

git pull origin master

git push dokku master

Create a shared location for the data

dokku storage:mount myapp /root/myapp:/app/data

dokku ps:restart myapp

Starting the sync process

Tell Dokku to run the gitsync process:

dokku ps:scale myapp gitsync=1

Inspect the logs for any errors:

dokku logs brahin --tail

Set up the webhook

Create a webhook on GitHub: go to your repo, Project Settings / Webhooks.

Set the Payload URL to root_url/_git/pull

Data Migration

If you're migrating from an older version, you can migrate your data by running:

dokku run myapp bundle exec rake data:copy_from_redis_to_files