Bitnami Redmine 업그레이드 + 이전 (Ubuntu 16.04 LTS)

윈도우에 설치된 Bitnami Redmine + VisualSVN을 우분투 서버로 이전하는 방법 정리.
오류, 오타가 있겠지만, 큰 흐름이라도 기록해 둬야...

0. 기존 자료 백업

모든 Redmine 서버 중지 (Manager GUI에서 모든 서비스 중지)
SVN 저장소의 각 프로젝트 별로 백업 파일 생성
svnadmin dump Project/Dir/To/Dump > __project_name__.dump
MySQL 데이터베이스 백업 파일 생성
mysqldump -u bitnami -p bitnami_redmine > backup.sql
Redmine 데이터 백업
cd redmine_install_dir/apps/redmine/htdocs
files 디렉토리 통째로 압축 (backup_files.zip)

1. Ubuntu + Bitnami Redmine 설치

Ubuntu 16.04.1 Desktop 버전 설치 + 소프트웨어 업데이트
sudo apt-get update
sudo apt-get upgrade
Bitnami Redmine installer 다운로드 + 설치
bitnami-~~~.run 다운로드
chmod 755 bitnami-~~~.run
sudo ./bitnami-~~~.run
설치 디렉토리 /opt/redmine-~~~, 설치 패키지: Subversion, Git 포함.
관리자 계정 ID와 암호 설정. 추후 DB 관리자 계정(admin이 아니라 root)의 암호도 동일하게 설정됨. (myphpadmin 실행해 접속 시 사용)

2. 백업 자료 복원

MySQL 데이터베이스 복원
/opt/redmine-~~~/apps/redmine/htdocs/config/database.yml에서 production 섹션 아래 DB(bitnami_redmine), user(bitnami) 확인하고, password 기록
sudo /opt/redmine-~~~/mysql/bin/mysql -u bitnami -p
기록해 둔 암호(database.yml) 이용해 로그인 후,
mysql> drop database bitnami_redmine;
mysql> create database bitnami_redmine;
mysql> exit
sudo /opt/redmine-~~~/mysql/bin/mysql -u bitnami -p bitnami_redmine < backup.sql
Redmine 데이터 복원  (files 디렉토리 내용 통째로 덮어쓰기)
cd /opt/redmine-~~~/apps/redmine/htdocs
sudo unzip backup_files.zip
cd /opt/redmine-~~~/apps/redmine/scripts
sudo ./redmineini.sh
SVN 저장소 복원
저장소 디렉토리(/opt/svn) 생성 후, 각 백업 프로젝트별로 저장소 디렉토리 생성과 백업 자료 복원 반복.
sudo mkdir /opt/svn
sudo /opt/redmine-~~~/subversion/bin/svnadmin create --fs-type fsfs /opt/svn/__project_name__
sudo /opt/redmine-~~~/subversion/bin/svnadmin load /opt/svn/__project_name__ < __project_name__.dump

3. 서비스 시작 및 자동 실행 설정

서비스 실행
/opt/redmine-~~~/ctlscript.sh start
부팅 시 자동시작하도록 스크립트 수정 (원하는 run level에 맞춰 수정)
sudo cp /opt/redmine-~~~/ctlscript.sh /etc/init.d/bitnami_redmine
sudo update-rc.d -f bitnami_redmine start 80 2 3 4 5 . stop 30 0 1 6 .
여기까지 하고 http://localhost/remine/으로 접속하면 기존 서버 설정이 제대로 이전되었는지 확인 가능. 단, SVN 연동은 아직 안 될 것임. (로컬에서 file:///로는 연결 가능하겠지만, 외부에서 http 등을 통한 접속은 불가)

4. SVN 접근 권한 설정

Bitname Remine이 제공하는 웹 서버와 SVN 저장소를 연계시켜 외부에서 http 프로토콜을 통해 SVN 서버로 활용할 수 있도록 함. SVN 서버와 Redmine 사용자가 동일하여, Redmine 사용자 정보(ID, 암호)를 SVN 서버에 그대로 사용(Redmine 암호 변경하면 SVN 서버도 동일한 암호로 접속 가능)하려면 https://docs.bitnami.com/installer/apps/redmine/의 고급 설정 부분을 참고해야 함.
여기서는 Redmine 사용자와 SVN 저장소 사용자를 따로 관리하는 것으로 함. 즉, http 서버에서 SVN 저장소(/opt/svn)에 대한 사용자 권한을 설정하며, 특히 http 서버는 DAV 기반으로 관리.
우선, SVN 저장소에 접근 가능한 사용자+암호 목록을 생성.
sudo touch /opt/svn/users
sudo /opt/redmine-~~~/apache2/bin/htpasswd /opt/svn/users __user_id__
또는 다음 명령처럼 일괄 적용할 수도 있음.
sudo /opt/redmine-~~~/apache2/bin/htpasswd -b /opt/svn/users __user_id__ __password__
SVN 저장소의 각 프로젝트 별 사용자 접근권한 지정
cd /opt/svn/
sudo vi authz
[/]
__user_id__ = [rw]
...
[__dir_name__:/]
__user_id__ = [rw] # r이면 읽기 권한만, w면 쓰기 권한만, rw면 읽고 쓰기 모두 가능.
...
http 설정 파일(/opt/redmine-~~~/apps/redmine/conf/httpd-app.conf)에 SVN 저장소(/opt/svn) 권한 관리 방법 명시 (아래 내용 추가)
<Location /svn>
  DAV svn
  SVNParentPath /opt/svn
  SVNListParentPath on
  Order deny,allow

  AuthType Basic
  AuthName "Subversion Repository"
  AuthUserFile "/opt/svn/users"
  require valid-user

  Allow from localhost
</Location>
웹 서비스 재시작
sudo /opt/redmine-~~~/ctlscript.sh restart apache
여기까지 하면, 로컬로, 또는 외부에서 /opt/svn/users 설정 시 사용했던 접속 ID와 암호로 http://__svn_server__/svn/__project_name__에 접근 가능.

5. Git 서버 및 접근권한 설정

Git 서버 운영을 위해 SSH나 HTTPS, Git 등의 프로토콜을 사용하는 것이 좋아 보이는데, 현재 설치된 서버와 설정을 고치고 사용자 계정 운영이 복잡해 질 것 같아 SVN과 유사하게 운용. 즉, /opt/gitrepos를 기본 저장소로 하고, http://__git_server__/git/__project_name__으로 외부에서 접근 가능하도록 하며, 사용자 접근 권한은 SVN의 권한 파일(/opt/svn/users)을 공유하는 방식.

우선, 새로 추가되는 /git/이라는 위치로의 접근을 git-http-backend가 처리하도록 수정해 주고, /git의 실제 위치(/opt/gitrepos)를 대응시키고 접근 권한 관리 방식을 명시해 주어야 한다. /opt/redmine-~~~/apache2/conf/bitnami/bitnami.conf에서, <VirtualHost __default__:80> 안쪽에 다음과 같이 내용 추가/수정.
<VirtualHost _default_:80>
  DocumentRoot "/opt/redmine-3.3.2-0/apache2/htdocs"
  <Directory "/opt/redmine-3.3.2-0/apache2/htdocs">
    Options Indexes FollowSymLinks
    AllowOverride All
    <IfVersion < 2.3 >
      Order allow,deny                        
      Allow from all
    </IfVersion>
    <IfVersion >= 2.3 >
      Require all granted
    </IfVersion>
  </Directory>
  SetEnv GIT_PROJECT_ROOT /opt/gitrepos
  SetEnv GIT_HTTP_EXPORT_ALL
  SetEnv REMOTE_USER=$REDIRECT_REMOTE_USER
  ScriptAlias /git/ /opt/redmine-3.3.2-0/git/libexec/git-core/git-http-backend/
  RewriteCond %{QUERY_STRING} service=git-receive-pack [OR]
  RewriteCond %{REQUEST_URI} /git-receive-pack$
  RewriteRule ^/git/ - [E=AUTHREQUIRED:yes]
  <Directory /opt/redmine-3.3.2-0/git>
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    AllowOverride None
    <IfVersion < 2.3 >
      Order allow,deny
      Allow from all
    </IfVersion>
    <IfVersion >= 2.3 >
      Require all granted
    </IfVersion>
  </Directory>
  Alias /git /opt/gitrepos
  <Location /git>
    Options Indexes FollowSymLinks MultiViews
    AuthType Basic
    AuthName "Git Repository"
    AuthUserFile "/opt/svn/users"
    Require valid-user
  </Location>

  # Error Documents
  ErrorDocument 503 /503.html
  # Bitnami applications installed with a prefix URL (default)
  Include "/opt/redmine-3.3.2-0/apache2/conf/bitnami/bitnami-apps-prefix.conf"
</VirtualHost>
저장소는 다음 과정을 통해 생성.
sudo mkdir /opt/gitrepos
cd /opt/gitrepos
sudo mkdir __project_name__ (예: TestProjectName.git)
sudo /opt/redmine-3.3.2-0/git/bin/git init --bare
sudo cp hooks/post-update.sample hooks/post-update
sudo /opt/redmine-3.3.2-0/git/bin/git update-server-info
sudo chown -R daemon:daemon .
cd ..
또는 다음과 같은 내용의 쉡 스크립트(예: create_project_repo.sh)를 생성하고, 실행(예: sudo ./create_project_repo.sh __project_name__)하도록 정리해도 된다.
#!/bin/bash
git=/opt/redmine-3.3.2-0/git/bin/git
WORKDIR=`pwd`
REPO=$1
if [ "$REPO" = "" ]; then
  echo "Usage: ./create_project.sh [PROJECT_NAME]"
  exit 1
fi

# create dir
echo $REPO
mkdir -p $REPO
cd $REPO

# init repo
$git init --bare
#touch git-daemon-export-ok
cp hooks/post-update.sample hooks/post-update
#$git config http.receivepack true # true will enable anonymous push
$git update-server-info
chown -R daemon:daemon .

# done
cd $WORKDIR
추가로, /opt/gitrepos/authz 파일을 생성해 권한 부여. (SVN과 유사한 방식으로~)

마지막으로, 웹 서비스 재시작
sudo /opt/redmine-~~~/ctlscript.sh restart apache
여기까지 하면, 로컬로, 또는 외부에서 /opt/svn/users 설정 시 사용했던 접속 ID와 암호로 Git 저장소에 접근 가능. (예: git clone http://__user_id__:__password__@__git_server__/git/__project_name__ __local_name__)
Redmine에서 저장소 지정할 때는 로컬 경로, 즉 /opt/gitrepos/__project_name__ 형태로 지정하는 것이 적절.

6. 정리

얼추 이상의 과정을 걸치면 아쉬운대로 사용할 수 있다.
나중에 짬 나면 조금씩 개선해 볼 사항들도 물론 있다. 귀찮다는 게 문제...

  1. http 대신 https 사용
  2. git에 http/https 대신 ssh 사용
  3. SVN/Git 저장소 권한을 Redmine 사용자 + 프로젝트 접근 권한과 연동 (참고 링크의 고급 연동 부분에 해당)

참고

댓글

이 블로그의 인기 게시물

환경개선부담금

[DevTip] Windows에서 tail 쓰기...