Skip to content

mongoshield erase

Record a GDPR erasure so restores never bring the data back.

Terminal window
mongoshield erase <namespace> <filter> [options]

Appends an erasure to the ledger next to the backups. Every later restore, rollback and copy deletes the matching documents again. --now also deletes them from the live database. Exact matches on strings are stored as keyed hashes (set MONGOSHIELD_ERASURE_SECRET), so the ledger does not keep the personal data.

ArgumentDescription
<namespace>requireddb.collection, a pattern like app.*, or *
<filter>requiredExtended JSON filter, e.g. '{"email": "ada@example.com"}'
OptionDescription
--reason <text>Why (required). Reference the request, not the personal data.
--by <name>Who requested or approved it (default: user@host).
--nowAlso delete the documents from the live database.
--uri <mongodb-uri>The live database for --now (default: config source.uri).
--to <storage-url>Where backups are stored: ./dir, file:///abs, s3://bucket/prefix (default: config).

The global options (--config, --json, --quiet, --verbose, --no-color, --yes) work here too.

Erase a user everywhere, now and in every future restore:

Terminal window
mongoshield erase app.users '{"email": "ada@example.com"}' --reason "GDPR request #4471" --now

Erase a customer's documents in every collection that has a userId:

Terminal window
mongoshield erase 'app.*' '{"userId": 1042}' --reason "account deletion 1042"