Bitbucket Server Backup Client を使用する

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

Backup Client に Bitbucket Data Center との互換性はありません

Bitbucket Server Backup Client には、クラスタ化された Bitbucket Data Center インスタンスとの互換性はありません (シングル ノードに切り替えた場合も同様)。

クラスタ化された Bitbucket Data Center インスタンスをバックアップするには、代わりに Bitbucket Server DIY Backup を使用する必要があります。

このページでは Bitbucket Server Backup Client の使用について説明します。会社のポリシーに沿ったデータ復旧計画を確立することを強く推奨します。

 

Backup Client を使用した開始方法

  1. Bitbucket Server Backup Client をダウンロードします。
  2. クライアントを、サーバー上の Bitbucket Server インスタンスが存在するディレクトリに展開します。

 

ご質問がある場合は、「FAQ - データの復元とバックアップ」を参照してください。

On this page:

動作の仕組み

Backup Client は、Bitbucket Server インスタンスをバックアップするための一般的かつユニバーサルな処理を含み、次の内容を実行します。

  1. Bitbucket Server アプリケーションへのアクセス、Bitbucket Server によって管理されているリポジトリ、および Bitbucket Server データベースを確認して、バックアップの全体的な時間を確認します。この状態は "メンテナンス モード" と呼ばれます。
  2. すべての Git およびデータベース操作が完了したことを確認します。
  3. Bitbucket Server ホーム ディレクトリおよび Bitbucket Server データベースのアプリケーション固有のバックアップを実行します。バックアップは汎用的なものであり、サーバーまたはデータベース構成に依存しません。 
  4. バックアップ ファイルをローカル ファイルシステムの指定された場所に、1 つの tar ファイルして保管します。 
  5. Bitbucket Server のメンテナンス モードのロックを解除します。

Bitbucket Server がメンテナンス モードのときに、Bitbucket Server の web インターフェイスにアクセスしようとしたり、Bitbucket Server のホスティング サーバーを使用しようとしたりすると、エラー メッセージが表示されます。

クライアントは Windows および Linux プラットフォームと Bitbucket Server バージョン 4.0 以降をサポートしていますが、個々の組織の IT ポリシーやプロセスに連携するような機能は提供していません。

Bitbucket Server Backup Client の使用時に利用が不可能になる時間を予測するための参考値として、弊社の内部使用では、Bitbucket Server のダウンタイムは 7–8 分 (リポジトリのサイズが合計 6 GB の場合) になりました。比較のために、同じリポジトリで Bitbucket Server DIY Backup を使用すると、一般にダウンタイムは 1 分未満になります。

バックアップ対象

Backup Client は次のすべてのデータをバックアップします。

  • Bitbucket Server が接続されているデータベース (内部または外部 DB)
  • 管理された Git リポジトリ
  • Bitbucket Server の監査ログ
  • インストール済みのプラグインとそれらのデータ

バックアップには次のファイルおよびディレクトリは含まれません。

  • export/*
  • log/* (except for the audit logs)
  • shared/data/db* (HSQL data in the DB is backed up, but the files on disk are not)
  • tmp
  • the plugins directory (except for the installed-plugins directory) 

クライアントを使用した Bitbucket Server のバックアップ

クライアントを使用して Bitbucket Server をバックアップする前に、ご使用の Bitbucket Server インスタンスと互換性のある Bitbucket Server Backup Client のリリースを使用していることを確認します

Backup Client はコマンド ライン ツールであり、プラグインではない (アプリケーションの UI はない) ため、Bitbucket Server のホーム ディレクトリにアクセス可能な外部のどこかから実行する必要があります。通常、Backup Client は Bitbucket Server で直接実行します。次のコマンドでクライアントを実行します。

cd <path/to/backup-config.properties file>
java -jar <path/to/bitbucket-backup-client.jar>

Configuration options are kept in the backup-config.properties file, an example of which is included with the client. This file is automatically read from the directory you were in when the bitbucket-backup-client is run. The properties are fully documented in the backup-config.properties file, but include:

bitbucket.home

バックアップまたは復元先にする、Bitbucket Server インスタンスのホーム ディレクトリの場所を指定します。必須

If omitted here it will be taken from the BITBUCKET_HOME environment variable or the Java system property of the same name if supplied to the Backup and Restore Client on the command line. As a required value, backup and restore will fail if it is not supplied through one of these mechanisms.

bitbucket.user

バックアップを実行する、管理権限を持つ Bitbucket Server ユーザーのユーザー名を定義します。必須

ここで省略した場合、同じ名前の Java システム プロパティから取得されます (コマンド ラインで Backup Client に指定していた場合)。これは必須の値であるため、これらのメカニズムのいずれかで指定されていない場合は、バックアップが失敗します。

bitbucket.password

バックアップを実行する、管理権限を持つ Bitbucket Server ユーザーのパスワードを定義します。必須

ここで省略した場合、同じ名前の Java システム プロパティから取得されます (コマンド ラインで Backup Client に指定していた場合)。これは必須の値であるため、これらのメカニズムのいずれかで指定されていない場合は、バックアップが失敗します。

bitbucket.baseUrl

バックアップを行う Bitbucket Server インスタンスのベース URL を定義します。必須

E.g. http://localhost:7990/bitbucket  or   http://bitbucketserver/.

ここで省略した場合、同じ名前の Java システム プロパティから取得されます (コマンド ラインで Backup Client に指定していた場合)。これは必須の値であるため、これらのメカニズムのいずれかで指定されていない場合は、バックアップが失敗します。

backup.home

Backup Client がバックアップ アーカイブなどの自身のファイルを保存する場所を定義します。

If not specified, these files are stored beneath the working directory for the Backup Client. Backup files will be stored in a backup subdirectory and logs will be stored in a logs subdirectory.

 

Note that on Windows, you must use two backslashes between paths.  E.g. C:\\path\\to\\folder or instead use the forward slash e.g. C:/path/to/folder.

The location defined by backup.home must not be located in the directory defined by bitbucket.home. If that is the case, the Backup Client will fail.

Alternatively, these properties can be given on the command-line, when they need to be prefixed with "-D", and be placed before the "-jar" parameter. For example:

java -Dbitbucket.password="admin" -Dbitbucket.user="admin" -Dbitbucket.baseUrl="http://localhost:7990" -Dbitbucket.home=path/to/bitbucket/home -Dbackup.home=path/to/backup-home -jar bitbucket-backup-client.jar

クライアントのバックアップのキャンセル

必要に応じて、実行中のクライアント バックアップ操作をキャンセルできます。

バックアップのキャンセル方法

  1. ターミナル (または Windows のコマンド プロンプト) でクライアントによって返されるキャンセル トークンをコピーします。

    $ ./bitbucket.diy-backup.sh
    [http://localhost:7990/bitbucket]  INFO: Prepared backup of DB bitbucket in /bitbucket-backup/bitbucket-db/
    building file list ... done.
    sent 4.17M bytes  received 484 bytes  2.78M bytes/sec
    total size is 121.12M  speedup is 29.06
    [http://localhost:7990/bitbucket]  INFO: Prepared backup of /bitbucket-home to /bitbucket-backup/bitbucket-home/
    [http://localhost:7990/bitbucket]  INFO: locked with '7187ae1824ce1ede38a8e7de4bccf58d9a8e1a7a'
    [http://localhost:7990/bitbucket]  INFO: backup started with '82c73f89e790b27fef3032e81c7071388ae4e371'
    [http://localhost:7990/bitbucket]  INFO: Waiting for DRAINED state....... done
    [http://localhost:7990/bitbucket]  INFO: db state 'DRAINED'
    [http://localhost:7990/bitbucket]  INFO: scm state 'DRAINED'
  2. ブラウザで Bitbucket Server インターフェイスに移動します。Bitbucket Server は次の画面を表示します。
  3. [バックアップを取消] をクリックし、キャンセル トークンを入力します。

  4. [バックアップを取消] をクリックします。

既存の DB を使用するように Bitbucket Server を復元

このセクションは、インストールの破損を修復するために Bitbucket Server を復元しているが、Bitbucket Server のバックアップ元の既存の DB を使用可能な場合に適用されます。このシナリオでは、Bitbucket Server は元のバックアップ元と同じサーバーに Bitbucket Server を復元しようとしていると見なします。

Restore Client は、Bitbucket Server の復元先と同じマシンで実行されている必要があります。復元で既存のデータを意図せず削除してしまうことがないよう、Restore Client は空白のホーム ディレクトリと空白のデータベースにのみ復元を行います。

Restore Client は復元元のバックアップに含まれる JDBC 接続構成を使用します。

次のプロセスに従います。

  1. Bitbucket Server インスタンスを停止します。
  2. 現在のホーム ディレクトリのコンテンツを削除し、空にします。
  3. データベースの既存のテーブルをドロップし、空にします。データベースは引き続き同じユーザー/パスワードで存在していて、次の関連ページの「Bitbucket Server データベースの作成セクションで説明されている構成を持っている必要があります。 
  4. Run the Restore Client using the following command (replacing 'path/to/bitbucket/home' and '/path/to/original/backup/file' with your own values):

    java -Dbitbucket.home="path/to/bitbucket/home" -jar bitbucket-restore-client.jar /path/to/original/backup/file
  5. 破損したインストールを修正するために Bitbucket Server を復元する場合、「Bitbucket Server アップグレード ガイド」のステップ 4 から 6 に従います。Bitbucket Server のバックアップに使用された Bitbucket Server バージョンと同じものを使用する必要があります。

新しく作成された DB を使用するように Bitbucket Server を復元 

新しく作成したデータベースに Bitbucket Server を復元する場合は、このセクションの説明に従ってください。このシナリオは、Bitbucket Server をバックアップ元とは異なるサーバーに復元することを前提としています。

復元プロセスはデータベースを問いません。つまり、バックアップの復元先のデータベースは、元のバックアップされたデータベースと異なる構成やタイプでもかまいません。

Bitbucket Server を復元する際には、Bitbucket Server の復元先のマシンで Restore Client が実行されている必要があります。復元で既存のデータを意図せず削除してしまうことがないよう、Restore Client は空白のホーム ディレクトリと空白のデータベースにのみ復元を行います。 

次のプロセスに従います。

  1. Bitbucket Server の実行に使用するユーザー アカウントを使用して、新しい空のホーム ディレクトリを作成します。
  2. データベースを作成します。次の関連ページの「Bitbucket Server データベースの作成セクションで説明されている構成を持っている必要があります。
  3. Restore Client を実行します。詳細については以降のセクションをご確認ください。
  4. Bitbucket Server インストールを実行する」の手順に従い、新しいサーバーに Bitbucket Server をインストールします。インストール先を空白のディレクトリにし、製品を以前のサーバーでサービスとして実行していた場合は同様にサービスとしてインストールします。
  5. 新しいインストールが正常に実行されていることを確認します。「Bitbucket Server の開始と停止」をご確認ください。この段階では、Bitbucket Server によるゼロからの構成のためのガイド (ライセンスの詳細や管理者ユーザーの確認など) が表示されます。これは予期される挙動です。
  6. 新しくインストールしたインスタンスを停止します。
  7. Delete the contents from the newly installed BITBUCKET_HOME
  8. Copy the contents of the restored BITBUCKET_HOME into the newly installed BITBUCKET_HOME.
  9. 新しくインストールされた Bitbucket Server を開始します。
  10. この段階で、次のようになります。
    1. 以前のサーバーと同じリリースのバイナリをインストールした場合、すべてが以前と同じようになり、個別のステップでアップグレードを行う必要があります。これは推奨アプローチです。
    2. 以前のリリースにインストールされていたリリースよりもあとのリリースのバイナリをインストールした場合、この段階でアップグレードが実行されます。

コマンド ラインから Restore Client を実行する

Restore Client をコマンド ラインから実行することもできます。このシナリオでは、新しいデータベースを作成済みであるため、使用すべき JDBC 接続を指定する必要があります。

The  Restore Client  uses the JDBC connection configuration specified in the  jdbc.driver ,   jdbc.url ,   jdbc.user  and   jdbc.password   parameters used in the command to run the Restore Client (see below). Once the database backup is successfully restored, the client will write the specified parameters to the  bitbucket-config.properties  file in the newly restored Bitbucket Server home directory, allowing the new instance to connect to the restored database once the steps outlined below are followed.

MySQL データベースへの復元を実行する前に、MySQL 用の JDBC はバンドルされていない点にご注意ください (ライセンス上の制限のため)。ドライバを自身でダウンロードおよびインストールする必要があります。

  1. MySQL Connector/J JDBC ドライバをダウンロード サイトからダウンロードします。

  2. ダウンロードした zip/tar.gz ファイルを解凍します。

  3. Copy the mysql-connector-java-5.1.XX-bin.jar file from the extracted directory to your <path/to/backup/client>/jdbc directory.

この例では、新しく作成された PostgreSQL への復元を行っています。

java -Djdbc.override=true -Djdbc.driver=org.postgresql.Driver -Djdbc.url=jdbc:postgresql://HOSTNAME:PORT/DATABASE -Djdbc.user=bitbucketuser -Djdbc.password=password -Dbitbucket.home="path/to/bitbucket/home" -jar /path/to/bitbucket-restore-client.jar /path/to/original/backup/file

Alternatively, you can configure these parameters on the  backup-config.properties file – make sure the file exists in the current working directory. A sample file is shipped with the client. The properties are fully documented in the backup-config.properties file and more details are described below:

bitbucket.home

The full path to a directory that the Restore Client will populate with the Bitbucket Server home data. This directory must be empty.
On Windows, you must use two backslashes ( \\ ) or a single forward slash ( / ) to separate paths. 

jdbc.override

By default, the Restore Client will restore into the same database that was backed up. If jdbc.override is set to true , the Restore Client will restore into the database specified by the jdbc properties in the table below. The database must be empty.

jdbc.driver 

Bitbucket Server が新しいデータベースへのログインに使用すべきドライバ クラスです。以降の例をご確認ください。

jdbc.url

新しいデータベースの接続の詳細です。JDBC URL の形式を持ちます。以降の例をご確認ください。

jdbc.user

Bitbucket Server が新しいデータベースへのログインに使用すべきユーザー名です。

jdbc.password

Bitbucket Server が新しいデータベースへのログインに使用すべきユーザー名です。

bitbucket.home.restore.whitelist

 

バックアップの復元時にターゲットのホーム共有ディレクトリに存在する可能性があるファイルとディレクトリの、コンマ区切りの一覧を定義します。これらのエントリに一致しないファイルがあった場合、処理に失敗します。

 

既定では、.snapshot、lost+found、.DS_Store がホワイトリストに追加されています。

JDBC プロパティの使用例

Example jdbc.driver and jdbc.url properties are shown below:

データベースjdbc.driverjdbc.url
MySQLcom.mysql.jdbc.Driver

jdbc:mysql://HOSTNAME:PORT/DATABASE?autoReconnect=true&characterEncoding=utf8&useUnicode=true&sessionVariables=storage_engine%3DInnoDB

Oracleoracle.jdbc.driver.OracleDriverjdbc:oracle:thin:@//HOSTNAME:PORT/SERVICE
PostgreSQLorg.postgresql.Driverjdbc:postgresql://HOSTNAME:PORT/DATABASE
SQL Servercom.microsoft.sqlserver.jdbc.SQLServerDriverjdbc:sqlserver://HOSTNAME:PORT;databaseName=DATABASE;

デバッグ ロギング

Debug logging can be turned on by adding the following to the logback.xml file in the working directory from where you're running the backup client. Create this file if it does not already exist.

logback.xml
<included><logger name="com.atlassian.bitbucket" level="DEBUG"/></included> 

関連ページ

最終更新日: 2021 年 1 月 4 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.