AI エージェント向け: ドキュメントインデックスは https://www.mongodb.com/ja-jp/docs/llms.txt で利用できます。すべてのページの markdown バージョンは、いずれかの URL パスに .md を追加することで利用できます。
Docs Menu

1 つのデータベースまたはコレクションの復元

スナップショットから単一のデータベースまたはコレクション(または特定のドキュメント)を復元するには、クエリ可能なバックアップを使用して単一のデータベースまたはコレクションをエクスポートし、ターゲットの配置に復元します。

Before you attempt a restore, ensure the host for your target deployment has sufficient storage space for the restore files and the restored database, plus additional space for dataset growth. Use db.stats() to find the current database size.

重要

To connect to a queryable backup instance from your own workstation, use the latest versions of MongoDB Database Tools, which include mongodump and mongorestore, and the latest version of mongosh.

mongodumpの古いバージョンには、コレクションオプション内のキーが間違った順序でダンプされる可能性がある問題が含まれています。詳しくは、 TOOLS-3411 を参照してください。

MongoDB Ops Manager を ローカル モードで実行する場合は、最新のバージョンではなく、MongoDB Ops Manager リリースの Database Tools 互換性テーブル に記載されているバージョンをインストールします。

クエリ可能なバックアップのスナップショットを使用して、データベースまたはコレクションのデータをエクスポートし、ターゲットの配置に復元できます。 次の手順では、Ops Manager によって提供されるトンネル[1]を介して、クエリ可能なバックアップのインスタンスに接続します。

注意

If the Daemon runs without access to the Internet, see Configure Deployment to Have Limited Internet Access to install the appropriate binaries.

1

クエリするバックアップの配置で、Optionsの下のをクリックし、Query を選択します。

配置をクリックしてスナップショットを表示し、Actions 列の下にある Query ボタンをクリックすることもできます。

2
  1. クエリするスナップショットを選択し、[Next] をクリックします。

  2. Start スナップショットをクエリするプロセス。2 要素認証を求められます。

  3. クエリ可能なスナップショットへの接続方法としてBackup Tunnelを選択します。[1]

  4. プラットフォームを選択してダウンロードします。

  5. ダウンロードしたファイルを解凍します。

    注意

    クエリ可能なスナップショットがマウントされるまで待ってから続行します。 スナップショットのマウント時間は、スナップショットのサイズによって異なります。 スナップショットがマウントされていることを確認するには、 Continuous Backupに移動し、 Restore Historyタブを選択します。 スナップショットがマウントされると、 Status列はマウント操作の日時を報告します。

  6. ターミナルまたはコマンド プロンプトを開き、解凍された <tunnel> ディレクトリに移動します。実行可能ファイルを実行してトンネルを開始します。

    トンネルのデフォルト ポートは27017です。 ポートを変更するには、次の例のように--localフラグを使用します。

    ./<tunnel executable> --local localhost:27020

    注意

    ポートを変更する場合は、接続時にポート情報を含める必要があります。

3

データベースのデータをエクスポートするには、

トンネルmongodump []1 に接続するには、次の オプションを含めます。

  • --port トンネルのポートに設定

  • --db エクスポートするデータベースの名前に設定

  • --out 空のディレクトリに設定して、データ ダンプを出力します。

    重要

    Ensure that the user running mongodump can write to the specified directory.

mongodump --port <port for tunnel> --db <single-database> --out <data-dump-path>

ポート 27020 で動作しているトンネルに接続して test データベースから /mydata/restoredata/ ディレクトリにデータをダンプするには、

mongodump --port 27020 --db test --out /mydata/restoredata/

mongodump outputs the test database files into the /mydata/restoredata/test/ directory.

If the mongodump is not in your PATH, specify the path for the tool.

コレクションのデータをエクスポートするには、

トンネルに接続するには以下のオプションがあります[1]

  • --port トンネルのポートに設定します。

  • --db エクスポートするデータベースの名前に設定します。

  • --collection 単一のコレクション用。

  • --out 空のディレクトリに設定して、データ ダンプを出力します。

    重要

    Ensure that the user running mongodump can write to the specified directory.

mongodump --port <port for tunnel> \
--db <single-database> \
--collection <collection-name> \
--out <data-dump-path>

ポート 27020 で動作しているトンネルに接続して restaurants コレクションのデータを test データベースから /mydata/restoredata/ ディレクトリにダンプするには、

mongodump --port 27020 \
--db test \
--collection restaurants \
--out /mydata/restoredata/

mongodump outputs the restaurants collection data into the /mydata/restoredata/test/restaurants.bson file.

4

単独のデータベースを復元するには、

Include the following mongorestore options:

  • --port 宛先クラスターのポートに設定します。

  • --db 宛先データベースの名前に設定します。

Optionally, you can include --drop to drop the database in the destination cluster if the database already exists.

mongorestore --port <port> --db <destination database> <data-dump-path/database> --drop

たとえば、/mydata/restoredata/test ディレクトリから新しいデータベース restoredTest に復元するには、次のように行います。

mongorestore --port 27017 --db restoredTest /mydata/restoredata/test --drop

The example assumes that the destination replica set's primary or the destination sharded cluster's mongos listens on port 27017.

単独のコレクションを復元するには、

Include the following mongorestore options:

  • --port 宛先クラスターのポートに設定します。

  • --db 宛先データベースの名前に設定します。

Optionally, you can include --drop to drop the collection in the destination cluster if the collection already exists.

mongorestore --port <port> --db <destination database> --collection <collection-name> <data-dump-path/dbname/collection.bson> --drop

たとえば、/mydata/restoredata/test/restaurants.bson データ ファイルから test2 データベース内の新しいコレクション rest2 に復元するには、次のように行います。

mongorestore --port 27017 --db test2 --collection rest2 /mydata/restoredata/test/restaurants.bson --drop

The example assumes that the destination replica set's primary or the destination sharded cluster's mongos listens on port 27017.

5

終了したら、クエリ可能なインスタンスを終了できます。

  1. Restore History を開き、配置アイテムの Status 列にカーソルを合わせます。

  2. [Cancel] をクリックします。

[1]( 1234 )あるいは、トンネル経由で接続する代わりに、提供されている X.509 PEM ファイルを使用して、クエリ可能なバックアップに直接接続することもできます。クエリ可能なバックアップに直接接続する場合は、ホスト名とポート、TLS/SSL オプション、および X.509 証明書を指定する必要があります。

重要

AES256-GCM で暗号化されたスナップショット復元後のマスター キー ローテーション

Ops Manager が AES256-GCM を使用して 暗号化したスナップショット を復元する場合は、復元の完了後に マスターキーをローテーションします 。