Various scripts to backup git repositories
Create an own script using these backup scripts. Run this script manually or use cron:
crontab -eadd for once a day:
0 5 * * * /home/user/bin/mybackup_script#!/bin/sh
# backup my git repositories
# backup gitolite
echo "#### HOST: gitolite.example.com"
backup-gitolite "git@gitolite.example.com" "backup_gitolite_example_com/"
# backup gitlab
echo "#### HOST: gitolab.example.com"
backup-gitlab "gitlab.example.com" "1234TOKENABC" "backup_gitlab_example_com/"
# backup github
echo "#### HOST: github.example.com"
backup-github simonwalz "backup_github_com/"Backup a git repository by its repository url:
backup-git-repo REPO_URL LOCAL_PATH| Option | Description | 
|---|---|
| REPO_URL | Full repository URL | 
| LOCAL_PATH | Local directory to save the git repository in. Can be a bare or a non-bare repository. Creates a bare repository if directory does not exist. | 
Backup all public git repositories of a GitHub user:
backup-github GITHUB_USER LOCAL_PATH_PREFIX [EXCLUDE_REPOS]| Option | Description | 
|---|---|
| GITHUB_USER | Your GitHub username | 
| LOCAL_PATH_PREFIX | Local directory prefix to save the git repositories in. If prefix ends on a `/` a separate directory is created. | 
| EXCLUDE_REPOS | (optional) Repositories to ignore. Use an extended regular expression to match repositories. E.g. '^Repo A$|^Repo B$' | 
Backup all git repositories of a GitLab user:
backup-gitlab GITLAB_HOST GITLAB_TOKEN LOCAL_PATH_PREFIX [EXCLUDE_REPOS] [GITLAB_HTTP_PROTO] [FETCH_PROTO] [GITLAB_USER] [CURL_OPTS]| Option | Description | 
|---|---|
| GITLAB_HOST | Pure hostname of the gitlab server. E.g. gitlab.example.com | 
| GITLAB_TOKEN | A GitLab API token. See GitLab Dokumentation | 
| LOCAL_PATH_PREFIX | Local directory prefix to save the git repositories in. If prefix ends on a `/` a separate directory is created. | 
| EXCLUDE_REPOS | (optional) Repositories to ignore. Use an extended regular expression to match repositories. E.g. '^Repo A$|^Repo B$' | 
| GITLAB_HTTP_PROTO | (optional) HTTP proto to use: https(default) orhttp | 
| FETCH_PROTO | (optional) Protocol to use for fetching the repositories: ssh(default),httpsorhttp | 
| FETCH_USER | (optional) Username to use for fetching the repositories. Default for SSH: gitDefault for HTTP: user | 
| CURL_OPTS | (optional) Additional curl command line options. E.g. '-u user:pass'for an additional HTTP BASIC authentication | 
Backup all git repositories of a Gitolite:
backup-gitolite GITOLITE_HOST LOCAL_PATH_PREFIX [EXCLUDE_REPOS]| Option | Description | 
|---|---|
| GITOLITE_HOST | Username and hostname of the gitolite server. E.g. git@gitolite.example.com | 
| LOCAL_PATH_PREFIX | Local directory prefix to save the git repositories in. If prefix ends on a `/` a separate directory is created. | 
| EXCLUDE_REPOS | (optional) Repositories to ignore. Use an extended regular expression to match repositories. E.g. '^Repo A$|^Repo B$' |