mongoshield init
Create mongoshield.config.ts (interactive).
mongoshield init [options]Asks where to store backups (Google Drive, Dropbox, GitHub artifacts, Backblaze B2, Cloudflare R2 or any storage URL), which environment variable holds the connection string, and whether to encrypt (optionally generating a key pair), then prints the next steps for that destination. With --yes or without a terminal it uses the flags below and their defaults. --preset atlas-free (or atlas-flex) writes a config for an Atlas Free or Flex cluster. --github sets up nightly backups in GitHub Actions instead: it signs in to the drive, generates the key pair and recovery kit, writes mongoshield.config.json and .github/workflows/mongoshield-backup.yml, sets the repository secrets with the gh CLI (or prints the commands) and starts the first run.
Options
Section titled “Options”| Option | Description |
|---|---|
--preset <name> | Start from a preset for your deployment: atlas-free, atlas-flex. |
--destination <gdrive|dropbox|github-artifacts|b2|r2|directory|s3|gs|az|sftp|url> | Where backups go, without the menu (needs --storage unless it has a default). |
--storage <storage-url> | Where backups will be stored: ./dir, gdrive://folder, b2://bucket/prefix?region=…, s3://…. Default: ./backups. |
--uri-env <VAR> | Environment variable that holds the MongoDB connection string. Default: MONGODB_URI. |
--keygen | Generate a key pair and encrypt backups with it. |
--recipient <age1…> | Encrypt backups for an existing public key instead. |
--key-file <path> | Where --keygen (or --github) writes the secret identity. Default: ./mongoshield.key. |
--github | Set up nightly backups in GitHub Actions in this repository (see above). |
The global options (--config, --json, --quiet,
--verbose, --no-color, --yes) work here too.
Examples
Section titled “Examples”Answer a few questions:
mongoshield initNon-interactive, for CI or provisioning scripts:
mongoshield init --yes --storage s3://acme-backups/prod --keygenBackblaze B2 (10 GB free, no card):
mongoshield init --yes --storage "b2://acme-backups/prod?region=us-west-004" --keygenNightly encrypted backups to Google Drive from GitHub Actions:
mongoshield init --githubA config for an Atlas Free (M0) cluster, encrypted with a new key:
mongoshield init --preset atlas-free --keygenMongoShield is MIT licensed and is not affiliated with, endorsed by or sponsored by MongoDB, Inc. MongoDB is a trademark of MongoDB, Inc.Privacy policy