LoginSignup
52
45

More than 5 years have passed since last update.

GitLabのバックアップとリストア

Last updated at Posted at 2014-06-03

GitLabに用意されているrake taskの使い方。

バックアップ

gitlabのルートディレクトリで以下を実行する。
実行ユーザはGitLabを動かしているユーザで行う。(通常はgitユーザ)

backup
$ bundle exec rake gitlab:backup:create RAILS_ENV=production

LOCK TABLESへのアクセス権限が無いと怒られたら下記を実行する。

mysql> GRANT LOCK TABLES ON `db_gitlab`.* TO 'user_gitlab'@'localhost';

バックアップの設定

config/gitlab.ymlの「backup:」セクションに以下を記述する。

項目 内容
path: バックアップファイルの出力先。デフォルトは(相対パスで)tmp/backups
keep_time: 世代管理で「残しておきたい秒数」を記述する。デフォルトは0で無期限。

リストア

gitlabのルートディレクトリで以下を実行する。
実行ユーザはGitLabを動かしているユーザで行う。(通常はgitユーザ)

restore
$ bundle exec rake RAILS_ENV=production gitlab:backup:restore BACKUP=<file_name>

cron設定

下記のようなshellファイルを作ってGitLabを動かしているユーザのcronに記述する。
PATHを通してあげないと怒られると思う。

gitlab-backup
#!/bin/bash

PATH=<gitユーザのPATHを参考にする>

export PATH

date
cd /home/git/gitlab
bundle exec rake gitlab:backup:create RAILS_ENV=production
52
45
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
52
45