Synology GitLab 자동 백업하기

Synology 2020.08.07 댓글 Plorence

jboxberger/synology-gitlab을 사용했습니다.

자동 백업 설정

컨테이너 환경 변수를 지정해 자동 백업하는 방법도 있는데, 그보다는 시놀로지의 작업 스케줄러를 사용해서 해볼까 합니다.
왜냐하면 관리하기 이게 더 편하기 때문입니다.
환경 변수는 지우려면 컨테이너를 종료해야 하기 때문에 귀찮습니다.

사용자 정의 스크립트를 클릭하고, 스케줄은 마음껏 선택합시다.

그리고 작업 설정에 아래 코드를 복사합니다.

# backup files will be saved in gitlab/backups directory usually ( /volume1/docker/gitlab/gitlab/backups )
# the backup contains the config files including !PASSWORDS! be shure to keep them in an safe place!
#
# Parameters:
# RAILS_ENV => we have only "production" environment so this parameter is pretty static
# CRON=1 => Parameter supress any output. To get detailed debug information remove the parameter from command ( CRON=0 will not work )

sudo /usr/local/bin/docker exec -it synology_gitlab bash -c "sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production CRON=1"

# yo can make the backups readyble by your DSM user but use theis only when you knwo what you're doing and do not have any
# security concerns
sudo chmod g+rw /volume1/docker/gitlab/backups/*.tar

해당 작업을 실행하시면 백업이 될 겁니다.

백업 파일 회전

백업 파일을 회전하지 않으면, 백업 파일이 계속 쌓이기 때문에 회전시켜줘야 합니다.
백업한 지 어느 정도 지난 파일은 삭제하기 원한다면 설정해줘야 합니다.

해당 컨테이너를 종료하고, 환경변수 GITLAB_BACKUP_EXPIRY 를 추가해줍시다.
값의 경우 초단위인데, 하루에 86400입니다.

저 같은 경우 백업한 지 2일이 지난 파일은 삭제하기 원했기 때문에 172800 로 설정하였습니다.

끝!

댓글