Skip to content

Various scripts to backup git repositories (github, gitlab, gitolite)

License

Notifications You must be signed in to change notification settings

simonwalz/script-git-backup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

git-backup

Various scripts to backup git repositories

Create an own script using these backup scripts. Run this script manually or use cron:

crontab -e

add for once a day:

0 5 * * * /home/user/bin/mybackup_script

Example script

#!/bin/sh
# backup my git repositories

# backup gitolite
echo "#### HOST: gitolite.example.com"
backup-gitolite "[email protected]" "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/"

Usage: backup-git-repo

Backup a git repository by its repository url:

backup-git-repo REPO_URL LOCAL_PATH
Options
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.

Usage: backup-github

Backup all public git repositories of a GitHub user:

backup-github GITHUB_USER LOCAL_PATH_PREFIX [EXCLUDE_REPOS]
Options
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$'

Usage: backup-gitlab

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]
Options
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) or http
FETCH_PROTO (optional) Protocol to use for fetching the repositories: ssh (default), https or http
FETCH_USER (optional) Username to use for fetching the repositories.
Default for SSH: git
Default for HTTP: user
CURL_OPTS (optional) Additional curl command line options. E.g. '-u user:pass' for an additional HTTP BASIC authentication

Usage: backup-gitolite

Backup all git repositories of a Gitolite:

backup-gitolite GITOLITE_HOST LOCAL_PATH_PREFIX [EXCLUDE_REPOS]
Options
Option Description
GITOLITE_HOST Username and hostname of the gitolite server. E.g. [email protected]
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$'

About

Various scripts to backup git repositories (github, gitlab, gitolite)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages