Recover Single Database

When only one MongoDB database needs recovery, initialize metadata from the offline copy and select that database for export.


I. Initialize the Database Directory

MONGODBDATA=/recovery-input/mongodb/source/dbpath
param sourceversion 8.0.0;
param sourcekind copy;
param sourcefrozen true;
b;
\l;
use appdb;
\dt;

II. Access the Database

2.1 View Database List

\l;

2.2 View Collection List and Information

use appdb;
\dt;
\d orders;

Confirm target collections from namespace and UUID in the catalog. Do not assign unbound sources directly to that database.


III. Export Data

unload coll orders;
unload db appdb;

Collection and database exports keep separate batch records. Repeating a command uses PDU's completion records to continue without parsing completed output units again.

ds batch status;
ds batch log;

IV. Output File Structure

Collection data is exported as BSON files or Canonical Extended JSON line files. Recovery commands generate offline candidate data without writing to the target database. Native records retain sources, success, failure, unresolved dependencies, original errors and checkpoints.

After export, record the native success and failure counts, unresolved dependencies and original errors reported by PDU, and retain the checkpoint. Resume uses native records and file metadata such as existence and size without rereading exported data.


V. Using the Recovered Data

Import exported BSON or Extended JSON into an isolated target. Use the original catalog to check indexes, validators and collection options separately. Exporting data files does not rebuild the complete instance.


Recover Multiple Databases

Use use to select each target database and execute unload db separately. Retain separate batch records, output and native completion states for each database.

unload db appdb;
use auditdb;
unload db auditdb;
MongoDB 文档