Skip to content

mongoshield init

Create mongoshield.config.ts (interactive).

Terminal window
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.

OptionDescription
--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.
--keygenGenerate 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.
--githubSet up nightly backups in GitHub Actions in this repository (see above).

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

Answer a few questions:

Terminal window
mongoshield init

Non-interactive, for CI or provisioning scripts:

Terminal window
mongoshield init --yes --storage s3://acme-backups/prod --keygen

Backblaze B2 (10 GB free, no card):

Terminal window
mongoshield init --yes --storage "b2://acme-backups/prod?region=us-west-004" --keygen

Nightly encrypted backups to Google Drive from GitHub Actions:

Terminal window
mongoshield init --github

A config for an Atlas Free (M0) cluster, encrypted with a new key:

Terminal window
mongoshield init --preset atlas-free --keygen