A PowerShell script that automatically backups all GitHub repositories of a user or an organisation to a local directory as a bare Git repository.
Download and unpack the latest release to your machine.
Open a PowerShell console at the location of the unpacked release and execute the ./backup_github_repositories.ps1.
Execute the following to backup all git repositories of a GitHub user into the subdirectory ./YYYY-MM-DD/
.
.\backup_github_repositories.ps1 -userName "user" -userSecret "token"
Execute the following to backup all git repositories of a GitHub organisation into the subdirectory ./YYYY-MM-DD/
.
.\backup_github_repositories.ps1 -userName "user" -userSecret "token" -organisationName "organisation"
Execute the following to backup all git repositories of a GitHub user into the directory C:\myBackupDirectory
and let the script prompt for the user secret.
.\backup_github_repositories.ps1 -userName "user" -backupDirectory "C:\myBackupDirectory"
Execute the following to backup all git repositories of a GitHub user into the subdirectory ./YYYY-MM-DD/
with a maximum concurrency of 2 background jobs.
.\backup_github_repositories.ps1 -userName "user" -backupDirectory "C:\myBackupDirectory" -maxConcurrency 2
Execute the following command to get detailed help.
Get-Help .\backup_github_repositories.ps1 -detailed
A bare repository only consists of the history and is not intended to be used directly. If you want to work on a specific repository you must first convert it into a non-bare Git repository. That will give you the working tree of a specific branch.
Execute the following to clone the bare Git repository .\my_project.git
into a non-bare Git repository .\my_project
:
git clone .\my_project.git