GitHub Backup
Getting Started
  • Filtering
  • Query Parameters
  • Refspecs
  • GitHub Repos
  • GitHub Releases
  • GitHub Gists
Report an Issue
GitHub
Getting Started
  • Filtering
  • Query Parameters
  • Refspecs
  • GitHub Repos
  • GitHub Releases
  • GitHub Gists
Report an Issue
GitHub
  • Getting Started

    • Introduction
    • GitHub Enterprise
    • Telemetry
  • Reference

    • GitHub Repos
    • GitHub Releases
    • GitHub Gists
  • Advanced

    • Filtering
    • Query Parameters
    • Refspecs

GitHub Repos

The primary use case for github-backup is to backup GitHub repositories, this is done using the github/repo backup type in your configuration file with an appropriate from directive to define the source of the repositories you wish to backup.

Examples

The following showcases the various combinations of kind and from directives you can use to backup repositories from GitHub.

Warning

Not every combination of kind and from is supported due to limitations in the way that GitHub's API works. If you use an unsupported combination, the tool will fail to run and provide you with an error message explaining why.

config.yaml
schedule: "0 * * * *"

backups:
    # Backup all of the repositories accessible to the user associated with the provided credentials
  - kind: github/repo
    from: "user"
    to: /backups/github
    credentials: !Token "your_github_pat"

    # Backup all of the public repositories owned by the specified user
  - kind: github/repo
    from: "users/<username>"
    to: /backups/github

    # Backup all of the repositories owned by the specified organization which the provided credentials have access to
  - kind: github/repo
    from: "orgs/<org>"
    to: /backups/github
    credentials: !Token "your_github_pat"

    # Backup a specific repository
  - kind: github/repo
    from: "repos/<owner>/<repo>"
    to: /backups/github

    # Backup all of the repositories starred by the currently authenticated user
  - kind: github/repo
    from: "starred"
    to: /backups/github/starred
    credentials: !Token "your_github_pat"

Filter Fields

Regardless of which backup kind and source you choose, you may use the following fields in your filter to determine which repositories should be included in your backup. These fields are accessed using the repo.<field> syntax, for example repo.fork to determine if a repository is a fork.

Tips

These fields are also available when using github/release or github/gist backups.

FieldTypeDescription (Example)
repo.namestringThe name of the repository (Hello-World)
repo.fullnamestringThe full-name of the repository (octocat/Hello-World)
repo.privatebooleanWhether the repository is private
repo.publicbooleanWhether the repository is public
repo.forkbooleanWhether the repository is a fork
repo.sizeintegerThe size of the repository, in kilobytes (1024).
repo.archivedbooleanWhether the repository is archived
repo.disabledbooleanReturns whether or not this repository disabled
repo.default_branchstringThe default branch of the repository (main)
repo.emptybooleanWhether the repository is empty (When a repository is initially created, repo.empty is true)
repo.templatebooleanWhether this repository acts as a template that can be used to generate new repositories
repo.forksintegerThe number of times this repository is forked
repo.stargazersintegerThe number of people starred this repository
{
  "repo": {
    // The name of the repository, excluding its owner
    "name": "Hello-World",
    // The full name of the repository, including its owner
    "fullname": "octocat/Hello-World",
    // Whether the repository is private (inverse of repo.public)
    "private": false,
    // Whether the repository is publicly accessible (inverse of repo.private)
    "public": true,
    // Whether the repository has been forked from another repository.
    "fork": false,
    // The size of the repository in kilobytes, will be zero for empty repositories.
    "size": 1024,
    // Whether the repository has been archived (and is read only).
    "archived": false,
    // Whether the repository has been disabled (and is read only).
    "disabled": false,
    // The name of the main branch for the repository.
    "default_branch": "main",
    // Whether the repository is empty (has a size of 0kB).
    "empty": false,
    // Whether the repository is a template which can be used to create new repositories.
    "template": false,
    // The number of times this repository has been forked.
    "forks": 0,
    // The number of people who have starred this repository.
    "stargazers": 501
  }
}
Edit this page
Last Updated: 27/06/2025, 00:29
Contributors: notheotherben
Next
GitHub Releases