Skip to content

JayTwoLab/backup_github

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub Repository Backup Script

English 🇰🇷 Korean

  • Backs up a GitHub repository.

  • Consists of a Windows Terminal cmd file, PowerShell ps1 file, and bash sh file.


1. CMD Usage Examples backup_github.cmd


1.1. Basic Usage (OutDir not specified → backup created in the current folder)

backup_github_full.cmd https://github.com/j2doll/discussion.git

Operation:

  • No GITHUB_TOKENLITE mode
  • Before execution, the following will be displayed:
Detected mode: LITE
This will back up: Code+Wiki only (no metadata).
Proceed with this mode? [y/N]:


1.2. Specify Output Path

backup_github_full.cmd https://github.com/j2doll/discussion.git D:\GH_Backups

→ Backup location:

D:\GH_Backups\discussion_backup\


1.3. Run in FULL Mode (using GITHUB_TOKEN environment variable)

setx GITHUB_TOKEN "ghp_XXXXX"
backup_github_full.cmd https://github.com/j2doll/discussion.git

Operation:

  • Token detected → FULL mode
  • Message before execution:
Detected mode: FULL
This will back up: Code+Wiki+Metadata (issues, PRs, reviews, labels, milestones, releases+assets).
Proceed with this mode? [y/N]:


1.4. When You Want to Force LITE Mode Only in CMD Without PowerShell

(Intentionally skip metadata backup)

set GITHUB_TOKEN=
backup_github_full.cmd https://github.com/j2doll/discussion.git


2. PowerShell Usage Examples backup_github.ps1

2.1. Basic Usage (OutDir not specified → current folder)

pwsh .\backup_github_full.ps1 -RepoUrl "https://github.com/j2doll/discussion.git"

2.2. Specify Output Path

pwsh .\backup_github_full.ps1 -RepoUrl "https://github.com/j2doll/discussion.git" -OutDir "D:\GH_Backups"

2.3. FULL Mode (specify token directly)

pwsh .\backup_github_full.ps1 -RepoUrl "https://github.com/j2doll/discussion.git" -Token "ghp_XXXXX"

2.4. FULL Mode (using environment variable)

$env:GITHUB_TOKEN="ghp_XXXXX"
pwsh .\backup_github_full.ps1 -RepoUrl "https://github.com/j2doll/discussion.git"

2.5. Backup Including Discussions (token required)

pwsh .\backup_github_full.ps1 -RepoUrl "https://github.com/j2doll/discussion.git" -IncludeDiscussions

2.6. Generate ZIP Archive

pwsh .\backup_github_full.ps1 -RepoUrl "https://github.com/j2doll/discussion.git" -Zip

2.7. After Backing Up Code+Wiki with CMD, Run Metadata Only in PowerShell (MetaOnly)

(Usually used when CMD internally triggers PowerShell automatically)

pwsh .\backup_github_full.ps1 -RepoUrl "https://github.com/j2doll/discussion.git" -OutDir "D:\GH_Backups" -MetaOnly


3. Summary

Scenario CMD Example PowerShell Example
Basic backup backup_github_full.cmd URL pwsh .\backup_github_full.ps1 -RepoUrl "URL"
Specify output path backup_github_full.cmd URL D:\path -OutDir "D:\path"
FULL mode (TOKEN) Run after setx GITHUB_TOKEN "xxx" -Token "xxx" or $env:GITHUB_TOKEN="xxx"
Include Discussions (available in CMD) -IncludeDiscussions
Generate ZIP (manual compression in CMD) -Zip

About

Script to back up GitHub storage 🇰🇷 github 저장소를 백업

Resources

License

Stars

Watchers

Forks

Packages

No packages published