bflemi3
bflemi3

Reputation: 6790

mongorestore - AtlasError - getting non-bucket system collections is unsupported

Failed: (AtlasError) getting non-bucket system collections is unsupported

I'm trying to use mongorestore to migrate data from one database to another. Both on Atlas. The dump is working fine, but mongorestore is outputting the below messages. I have no clue what this means and a google search renders nothing remotely close. I've added hyphens to the beginning of each line of the output to make it more readable.

-- using write concern: &{majority false 0}
-- will listen for SIGTERM, SIGINT, and SIGKILL
-- connected to node type: replset
-- The --db and --collection flags are deprecated for this use-case; please use --nsInclude instead, i.e. with --nsInclude=${DATABASE}.${COLLECTION}
-- got error from options parsing: (AtlasError) getting non-bucket system collections is unsupported
-- Failed: (AtlasError) getting non-bucket system collections is unsupported
-- 0 document(s) restored successfully. 0 document(s) failed to restore.

The command I'm running

mongorestore --uri="mongodb+srv://username:[email protected]/$DEV_DATABASE" \
  --preserveUUID \
  --drop \
  --nsFrom="$PROD_DATABASE.*" \
  --nsTo="$DEV_DATABASE.*" \
  --verbose \
  "dump/$PROD_DATABASE"

I've also tried creating an archive file with mongodump and using that with --archive="filename", as well as piping stdout to mongorestore. I've also checked that the user I'm using has the correct privileges. They have the role of Atlas admin, which I'm assuming is correct. The dev cluster I'm trying to restore to is an M0 if that makes any difference.

I should also point out that I have minimal Mongo management experience, so I'm sure there's something I've overlooked. Thanks for your help.

Upvotes: 1

Views: 319

Answers (1)

Joe
Joe

Reputation: 28326

MongoDB records the collection UUIDs in a separate system collection.

The --preserveUUID option instructs mongorestore to create the collection, and force it to use the UUID from the source system.

The error message indicates that Atlas is refusing to allow you to access or modify that system collection.

Run without the --preserveUUID option when restoring to Atlas.

Upvotes: 1

Related Questions