Install
MongoShield needs Node.js 22.12 or newer. It also runs on Bun 1.4 and
Deno 2.9 or newer (bunx --bun mongoshield, deno run -A npm:mongoshield);
see the Bun and Deno guide for what is tested there.
The CLI
Section titled “The CLI”Run it without installing:
npx mongoshield --helpOr install it into a project (recommended, so the version is pinned):
npm install --save-dev mongoshield mongodbnpx mongoshield --helpA Docker image is also available (ghcr.io/shamalrathnayake/mongoshield); see the
Docker guide.
The library
Section titled “The library”npm install mongoshield mongodbmongodb (driver 6.10+ or 7.x) is a peer dependency, so MongoShield uses the same driver
version as your application and can share its MongoClient.
Optional packages
Section titled “Optional packages”Cloud SDKs are optional peer dependencies. Install only what you use; MongoShield loads them lazily and tells you which package is missing if one is needed.
| For | Install |
|---|---|
| S3, Cloudflare R2, Backblaze B2, MinIO, DigitalOcean Spaces, Wasabi | @aws-sdk/client-s3 @aws-sdk/lib-storage |
| Google Cloud Storage | @google-cloud/storage |
| Azure Blob Storage | @azure/storage-blob @azure/identity |
| SFTP | ssh2 |
| AWS KMS | @aws-sdk/client-kms |
| Google Cloud KMS | @google-cloud/kms |
| Azure Key Vault | @azure/keyvault-keys @azure/identity |
| OpenTelemetry traces and metrics | @opentelemetry/api |
Local directories, Google Drive (gdrive://, plain fetch) and the in-memory storage
used in tests need nothing extra.
Storage URLs
Section titled “Storage URLs”The CLI and config file name storage with a URL. Credentials never go in the URL; each
service uses its usual credential chain (AWS environment and profiles, Google
Application Default Credentials, Azure DefaultAzureCredential, an SSH key or agent,
a Dropbox refresh token in MONGOSHIELD_DROPBOX_TOKEN).
| URL | Storage |
|---|---|
./backups, /var/backups, file:///abs/path | a local directory |
s3://bucket/prefix?region=…&endpoint=… | S3 or an S3-compatible service |
gs://bucket/prefix | Google Cloud Storage |
az://account/container/prefix | Azure Blob Storage |
sftp://user@host:port/path?fingerprint=SHA256:… | SFTP |
gdrive://folder | Google Drive (token in MONGOSHIELD_GDRIVE_TOKEN, from mongoshield login gdrive) |
dropbox://folder | Dropbox (App folder; token from mongoshield login dropbox in MONGOSHIELD_DROPBOX_TOKEN) |
An endpoint=… parameter is a plain https://host[:port]: one with user info or a query
string (an Azure SAS token, presigned S3 parameters) is refused, because those are
credentials. On az:// URLs that sign in with DefaultAzureCredential, an endpoint
outside Azure Storage's own domains (*.core.windows.net and the sovereign clouds) is
refused too, since the credential sends it a bearer token; add allowCustomEndpoint=true
for a host you trust, such as Azurite.
Optional: the age CLI
Section titled “Optional: the age CLI”You do not need it to use MongoShield. It is worth having on the machine where you keep your recovery key, so you can confirm you could decrypt a backup without MongoShield (age installation).
MongoShield is MIT licensed and is not affiliated with, endorsed by or sponsored by MongoDB, Inc. MongoDB is a trademark of MongoDB, Inc.Privacy policy