0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

GitLabCEをS3にバックアップする時のディレクトリを DIRECTORY= で指定する

Last updated at Posted at 2020-01-12

複数のGitLabCEのバックアップを AWS S3 に保管する場合、サブディレクトリを切って、GitLabCEごとに置きたくなりますが、公式ドキュメントだと分かりづらかったのでやり方をメモします。

環境は以下の通りです。

  • GitLabCE (12.1.6)
  • Amazon Linux (ver1)
  • yumインストール

方法は簡単で、バックアップコマンドに DIRECTORY=<S3のPath> を追加で指定します。

gitlab:backup:create DIRECTORY=onpre-gitlab01

cronでやるなら以下の様に設定するだけです。

# Backup gitlab weekly
30 15 * * SUN root gitlab-rake gitlab:backup:create DIRECTORY=onpre-gitlab01

なお、ドキュメントを読んで気づきましたが、12.2以降は以下の gitlab-backup コマンドが推奨される様です。私の環境はギリギリ12.1だったため、従来の gitlab-rake を実行しています。

0 2 * * * /opt/gitlab/bin/gitlab-backup create CRON=1

補足情報

GitLabCEにはS3にバックアップを取得する機能があります。

Using Amazon S3

ドキュメントの記述は以下の様になっていて、バケットは指定できてもディレクトリは指定できない様に見えます。

gitlab_rails['backup_upload_connection'] = {
  'provider' => 'AWS',
  'region' => 'eu-west-1',
  'aws_access_key_id' => 'AKIAKIAKI',
  'aws_secret_access_key' => 'secret123'
  # If using an IAM Profile, don't configure aws_access_key_id & aws_secret_access_key
  # 'use_iam_profile' => true
}
gitlab_rails['backup_upload_remote_directory'] = 'my.s3.bucket'

通常は困りませんが、複数のオンプレGitLabのバックアップを1つのバケットに置きたい場合、どれがどのバックアップなのかわからなくなってしまいます。具体的にはGitLabのバックアップファイルは以下の様な名前になります。

1578819848_2020_01_12_12.1.6_gitlab_backup.tar

この様に、何らかのIDと日付とバージョン_gitlab_backup.tar となるため、同一バージョンが複数ある場合見分けがとてもつきにくくなってしまう問題がありましたので、調べたところ以下の記述を発見しました。

stack overflow - Gitlab backup to S3 bucket

試したところ、問題なく動作したのでこちらに書きました。これで快適なGitLabバックアップライフが送れますね、エンジョイ!

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?