Skip to content

Avicted/github_clone_all

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

GitHub Repository Backup Script

This Bash script automates cloning or updating all repositories owned by a the authenticated user. It uses the GitHub API and SSH to securely back up repositories to a local directory.

Features

  • Fetches all repositories owned by the authenticated user.
  • Supports --dry-run mode to preview actions without cloning.
  • Automatically handles pagination for large accounts.
  • Uses git clone --recurse-submodules for full repository backups.

Requirements

Configuration

Set your target directory in the script:

CLONE_DIR="/home/username/my-github-projects"

Export your GitHub token before running:

export GITHUB_TOKEN="your_token_here"

Start the SSH agent before running:

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519

# Afterwards kill the agent with:
ssh-agent -k

Usage

Make the script executable:

chmod +x backup_github_repos.sh
./backup_github_repos.sh -h
Usage: backup_github_repos.sh [options]

Options:
    --dry-run        Print actions without cloning
    -h, --help       Show this help and exit

Environment:
    GITHUB_TOKEN     GitHub token (required)

Perform a dry run (no cloning):

# No cloning, just print actions
./backup_github_repos.sh --dry-run  

# Clone or update repositories
./backup_github_repos.sh

Output

  • Cloned repositories are stored in the directory specified by CLONE_DIR.
  • Existing repositories are updated.
  • Progress and errors are printed to the console.

License

This script is provided as-is under the MIT License.

About

This Bash script automates cloning or updating all repositories owned by a specified GitHub user. It uses the GitHub API and SSH to securely back up repositories to a local directory.

Resources

License

Stars

Watchers

Forks

Contributors

Languages