Gitlab Backup & Restore 방법

1. Backup 방법

sudo gitlab-rake gitlab:backup:create

백업을 하면 아래 경로에 백업 파일이 생성

  • /var/opt/gitlab/backups/
drwxr-----.  2 git  root      4096 2017-01-06 09:22 .
drwxr-xr-x. 13 root root      4096 2017-01-05 13:39 ..
-rw-------.  1 git  git  732047360 2017-01-06 09:20 1483662009_2017_01_06_gitlab_backup.tar

2. Restore 방법

먼저 2개의 서비스를 중지 시키고 상태를 확인

sudo gitlab-ctl stop unicorn
sudo gitlab-ctl stop sidekiq
# Verify
sudo gitlab-ctl status

백업된 파일을 기본 Backup 폴더로 위치

sudo cp 1393513186_2014_02_27_gitlab_backup.tar /var/opt/gitlab/backups/

Restore 명령

sudo gitlab-rake gitlab:backup:restore BACKUP=1393513186_2014_02_27

아래와 같은 에러 발생 (나의 경우)

rake aborted!
TypeError: no implicit conversion of nil into String

근본적인 방법은 아니지만, 백업 파일이 1개인 경우 백업 파일 이름없이 명령을 사용하면 해당 문제는 해결

sudo gitlab-rake gitlab:backup:restore 

위의 경우도 권한의 문제가 발생하니, 백업 파일의 666 이상의 권한과 디렉토리의 777 권한을 설정

기본적으로 git 계정으로 r 권한만 설정 되어 있음

sudo chmod 777 /var/opt/gitlab/backups/
sudo chmod 666 /var/opt/gitlab/backups/*

성공적으로 진행 되면 모든 데이터가 삭제 된다고 묻는 내용이 나오고 yes 키인하면 성공!!

3. 자동 백업

  • 서버측 스크립트(백업) : gitlab_backup.sh
#/bin/bash
sudo chmod 755 /var/opt/gitlab/backups/
sudo rm -rf /var/opt/gitlab/backups/*
sudo gitlab-rake gitlab:backup:create
sudo chmod 644 /var/opt/gitlab/backups/*
  • 클라이언트 백업 실행 및 복사 : gitlab_backup.bat
    계정의 ssh 의 공개키기반 자동 로그인 및 sudoers 에 NOPASSWD 옵션 추가
ssh -t [서버] script/gitlab_backup.sh
scp [서버]:/var/opt/gitlab/backups/* .


'Dev > Linux' 카테고리의 다른 글

ubuntu server 12.04  (0) 2013.10.28

Bonobo - Simple git server for Windows

- Git 서버를 윈도우즈 환경에서 운영하기 위한 플랫폼 

- IIS 7 이상, .NET Framework 4.5, ASP.NET MVC 4 환경 



# 설치 

- IIS 설치 : Windows 7 이상이면 "프로그램 및 기능" - "Windows 기능 겨키/끄기" 에서 설치 가능 

  * 응용 프로그램 개발 기능에서 .NET 4.5 확장성 및 ASP.NET 4.5 활성화 

- .NET Framework 4.5 설치 (Windows 8.1 이상은 이미 설치 됨) 

   https://www.microsoft.com/ko-KR/download/details.aspx?id=30653

- ASP.NET MVC 4 (http://www.asp.net/mvc/mvc4)


- Bonobo Git Server 다운로드 후, 압축을 풀고 해당 디렉토리를 IIS 응용프로그램으로 가상디렉토리 설정 

- 해당 디렉토리를 IIS 계정 (IIS_IUSER) 쓰기 권한 부여 

- 필요하다면 ASP.NET의 IIS 등록 

  (관리자 권한 : %windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -ir )


+ Recent posts