git_backup

package module
v1.7.1-0...-9bae3fb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 14, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

README

git-backup

A cli to pull all your git repositories for backup purposes. It is completely stand-alone. You don't even need to install git.

Download

The latest version can be downloaded from the releases page.

Configuration File

The configuration file supports go templating to load secrets and other variables from the environment. An example yaml-Configuration looks like:

# The github section contains backup jobs for
# GitHub and GitHub Enterprise
github:
  # (optional) The job name. This is used to
  # create a subfolder in the backup folder.
  # (default: GitHub)
  - job_name: github.com
    # (optional) Set this url to connect to
    # your self-hosted github install.
    # (default: https://api.github.com)
    url: https://github.mydomain.com
    # (required) The GitHub personal access
    # token. Create one with the scopes:
    # "read:org, repo"
    # https://github.com/settings/tokens/new?scopes=repo,read:org
    access_token: '{{ env "GITHUB_PAT" }}'
    # (optional) Back up repos you own.
    # (default: true)
    owned: true
    # (optional) Back up repos you starred.
    # (default: true)
    starred: true
    # (optional) Back up repos on which you
    # are a collaborator. (default: true)
    collaborator: true
    # (optional) Back up repos owned by
    # organisations of which you are a member.
    # (default: true)
    org_member: true
    # (optional) A list of repositories to backup.
    # Will be merged with the other discovery mechanisms
    # and it's result filtered with excluded repos.
    # (default: [])
    repositories:
      - ChappIO/git-backup
    # (optional) Backup all public repositories of these
    # organizations, even if you are not a member.
    # Will be merged with the other discovery mechanisms
    # and it's result filtered with excluded repos.
    # (default: [])
    organization:
      - golang
    # (optional) Exclude this list of repos
    # or whole organizations/users
    exclude:
      - my-excluded-org
      - my-excluded-user
      - my-namespace/excluded-repository-name
# The gitlab section contains backup jobs for
# GitLab.com and GitLab on premise
gitlab:
  # (optional) The job name. This is used to
  # create a subfolder in the backup folder.
  # (default: GitLab)
  - job_name: gitlab.com
    # (optional) Set this url to connect to
    # your self-hosted gitlab install.
    # (default: https://gitlab.com/)
    url: https://gitlab.mydomain.com
    # (required) The GitLab access token.
    # Create one with the scopes: "api"
    # https://gitlab.com/-/profile/personal_access_tokens?scopes=api&name=git-backup
    access_token: '{{ env "GITLAB_PAT" }}'
    # (optional) Back up repos you own.
    # (default: true)
    owned: true
    # (optional) Back up repos you starred.
    # (default: true)
    starred: true
    # (optional) Back up repos owned by
    # teams of which you are a member.
    # (default: true)
    member: true
    # (optional) A list of repositories to backup.
    # Will be merged with the other discovery mechanisms
    # and it's result filtered with excluded repos.
    # (default: [])
    repositories:
      - gnuwget/wget2
      - gitlab-org/api/client-go
    # (optional) Backup all public projects of these groups
    # (including subgroups), even if you are not a member.
    # Will be merged with the other discovery mechanisms
    # and it's result filtered with excluded repos.
    # (default: [])
    organization:
      - gnuwget
    # (optional) Exclude this list of repos
    # or whole organizations/users
    exclude:
      - my-excluded-org
      - my-excluded-user
      - my-namespace/excluded-repository-name

Usage: CLI

Usage: git-backup

Options:
  -backup.path string
      The target path to the backup folder. (default "backup")
  -config.file string
      The path to your config file. (default "git-backup.yml")
  -backup.fail-at-end
      Fail at the end of backing up repositories, rather than right away.
  -backup.bare-clone
      Make bare clones without checking out the main branch.
  -insecure
      Use this flag to disable verification of SSL/TLS certificates
  -version
      Show the version number and exit.

Usage: Docker

First, create your git-backup.yml file at /path/to/your/backups.

Then update your backups using the mounted volume.

docker run -v /path/to/backups:/backups ghcr.io/chappio/git-backup:1
Parameters

You can specify several parameters when starting this container.

Parameter Description
-v /path/to/backups:/backups Mount the folder where you want to store your backups and read you configuration file.
-e TZ=Europe/Amsterdam Set the timezone used for logging.
-e PUID=0 Set the user id of the unix user who will own the backup files in /backup.
-e PGID=0 Set the group id of the unix user's group who will own the backup files.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Github []*GithubConfig `yaml:"github"`
	GitLab []*GitLabConfig `yaml:"gitlab"`
}

func LoadFile

func LoadFile(path string) (out Config, err error)

func LoadReader

func LoadReader(reader io.Reader) (out Config, err error)

func (*Config) GetSources

func (c *Config) GetSources() []RepositorySource

type GitLabConfig

type GitLabConfig struct {
	URL          string   `yaml:"url,omitempty"`
	JobName      string   `yaml:"job_name"`
	AccessToken  string   `yaml:"access_token"`
	Starred      *bool    `yaml:"starred,omitempty"`
	Member       *bool    `yaml:"member,omitempty"`
	Owned        *bool    `yaml:"owned,omitempty"`
	Exclude      []string `yaml:"exclude,omitempty"`
	Repositories []string `yaml:"repositories,omitempty"`
	Organization []string `yaml:"organization,omitempty"`
	// contains filtered or unexported fields
}

func (*GitLabConfig) GetName

func (g *GitLabConfig) GetName() string

func (*GitLabConfig) ListRepositories

func (g *GitLabConfig) ListRepositories() ([]*Repository, error)

func (*GitLabConfig) Test

func (g *GitLabConfig) Test() error

type GithubConfig

type GithubConfig struct {
	JobName      string   `yaml:"job_name"`
	AccessToken  string   `yaml:"access_token"`
	URL          string   `yaml:"url,omitempty"`
	Starred      *bool    `yaml:"starred,omitempty"`
	OrgMember    *bool    `yaml:"org_member,omitempty"`
	Collaborator *bool    `yaml:"collaborator,omitempty"`
	Owned        *bool    `yaml:"owned,omitempty"`
	Exclude      []string `yaml:"exclude,omitempty"`
	Repositories []string `yaml:"repositories,omitempty"`
	Organization []string `yaml:"organization,omitempty"`
	// contains filtered or unexported fields
}

func (*GithubConfig) GetName

func (c *GithubConfig) GetName() string

func (*GithubConfig) ListRepositories

func (c *GithubConfig) ListRepositories() ([]*Repository, error)

func (*GithubConfig) Test

func (c *GithubConfig) Test() error

type Repository

type Repository struct {
	GitURL   url.URL
	FullName string
}

func (*Repository) CloneInto

func (r *Repository) CloneInto(path string, bare bool) error

type RepositorySource

type RepositorySource interface {
	GetName() string
	Test() error
	ListRepositories() ([]*Repository, error)
}

Directories

Path Synopsis
cmd
git-backup command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL