Skip to content

Latest commit

 

History

History
163 lines (102 loc) · 3.79 KB

File metadata and controls

163 lines (102 loc) · 3.79 KB

github 저장소 백업 스크립트

English 🇰🇷 Korean

  • github 저장소를 백업합니다.

  • 윈도우즈 터미널 cmd 파일, 파워쉘 ps1 파일, bash sh 파일로 구성


1. CMD 사용 예제 backup_github.cmd


1.1. 기본 사용 (OutDir 미지정 → 현재 폴더에 백업 생성)

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

동작:

  • GITHUB_TOKEN 없음 → LITE 모드

  • 실행 전에 아래와 같이 표시:

    Detected mode: LITE
    This will back up: Code+Wiki only (no metadata).
    Proceed with this mode? [y/N]:
    


1.2. 출력 경로 지정

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

→ 백업 위치:

D:\GH_Backups\discussion_backup\


1.3. FULL 모드 실행 (환경 변수 GITHUB_TOKEN 사용)

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

동작:

  • 토큰 감지 → FULL 모드

  • 실행 전 메시지:

    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. CMD 내에서 PowerShell 없이 강제 LITE만 실행하고 싶을 때

(의도적으로 메타데이터 백업 생략)

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


2. PowerShell 사용 예제 backup_github.ps1

2.1. 기본 사용 (OutDir 미지정 → 현재 폴더)

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

2.2. 출력 경로 지정

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

2.3. FULL 모드 (토큰 직접 지정)

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

2.4. FULL 모드 (환경 변수 이용)

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

2.5. Discussions까지 포함 백업 (토큰 필요)

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

2.6. ZIP 압축까지 생성

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

2.7. CMD에서 코드+위키 백업 후, PS에서 메타데이터만 실행 (MetaOnly)

(일반적으로 CMD가 내부적으로 자동 호출할 때 사용)

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


3. 요약

상황 CMD 예제 PS 예제
기본 백업 backup_github_full.cmd URL pwsh .\backup_github_full.ps1 -RepoUrl "URL"
출력 경로 지정 backup_github_full.cmd URL D:\path -OutDir "D:\path"
FULL 모드 (TOKEN) setx GITHUB_TOKEN "xxx" 후 실행 -Token "xxx" 또는 $env:GITHUB_TOKEN="xxx"
Discussions까지 (CMD에서 가능) -IncludeDiscussions
ZIP 생성 (CMD에서 수동 압축) -Zip