スナップショットから単一のデータベースまたはコレクション(または特定のドキュメント)を復元するには、クエリ可能なバックアップを使用して単一のデータベースまたはコレクションをエクスポートし、ターゲットの配置に復元します。
Considerations
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.
クエリ可能なスナップショットへのバックアップ トンネルを開きます。
クエリするスナップショットを選択し、[Next] をクリックします。
Start スナップショットをクエリするプロセス。2 要素認証を求められます。
クエリ可能なスナップショットへの接続方法としてBackup Tunnelを選択します。[1]
プラットフォームを選択してダウンロードします。
ダウンロードしたファイルを解凍します。
注意
クエリ可能なスナップショットがマウントされるまで待ってから続行します。 スナップショットのマウント時間は、スナップショットのサイズによって異なります。 スナップショットがマウントされていることを確認するには、 Continuous Backupに移動し、 Restore Historyタブを選択します。 スナップショットがマウントされると、 Status列はマウント操作の日時を報告します。
ターミナルまたはコマンド プロンプトを開き、解凍された <tunnel> ディレクトリに移動します。実行可能ファイルを実行してトンネルを開始します。
トンネルのデフォルト ポートは
27017です。 ポートを変更するには、次の例のように--localフラグを使用します。./<tunnel executable> --local localhost:27020 注意
ポートを変更する場合は、接続時にポート情報を含める必要があります。
クエリ可能なバックアップから単一のデータベースまたはコレクションをエクスポートするには、mongodump を使用します。
- データベースのデータをエクスポートするには、
トンネル
mongodump[]1 に接続するには、次の オプションを含めます。mongodump --port <port for tunnel> --db <single-database> --out <data-dump-path> - コレクションのデータをエクスポートするには、
トンネルに接続するには以下のオプションがあります[1] 。
--portトンネルのポートに設定します。--dbエクスポートするデータベースの名前に設定します。--collection単一のコレクション用。
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/ mongodumpoutputs therestaurantscollection data into the/mydata/restoredata/test/restaurants.bsonfile.
単一のデータベースまたはコレクションを復元するには、mongorestore を使用します。
- 単独のデータベースを復元するには、
Include the following
mongorestoreoptions:Optionally, you can include
--dropto 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
mongorestoreoptions:Optionally, you can include
--dropto 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.
| [1] | ( 1 、 2 、 3 、 4 )あるいは、トンネル経由で接続する代わりに、提供されている X.509 PEM ファイルを使用して、クエリ可能なバックアップに直接接続することもできます。クエリ可能なバックアップに直接接続する場合は、ホスト名とポート、TLS/SSL オプション、および X.509 証明書を指定する必要があります。 |
重要
AES256-GCM で暗号化されたスナップショット復元後のマスター キー ローテーション
Ops Manager が AES256-GCM を使用して 暗号化したスナップショット を復元する場合は、復元の完了後に マスターキーをローテーションします 。