mongoshield prune
Delete backups that the retention policy no longer keeps.
mongoshield prune [options]Keeps the newest backup of each period (like restic/borg --keep-*). The newest backup, held backups and invalid backups are never removed. Without count flags the policy comes from retention in mongoshield.config.ts.
Only the backups of the configured source and selection (include/exclude) are pruned; backups of other sources or selections in the same storage are left alone. --all-sources applies the policy to every backup in the storage.
Options
Section titled “Options”| Option | Description |
|---|---|
--last <n> | Keep the N newest backups. |
--hourly <n> | Keep the newest backup of each of the last N hours. |
--daily <n> | Keep the newest backup of each of the last N days. |
--weekly <n> | Keep the newest backup of each of the last N ISO weeks. |
--monthly <n> | Keep the newest backup of each of the last N months. |
--yearly <n> | Keep the newest backup of each of the last N years. |
--min-verified <n> | Always keep at least N verified backups. |
--dry-run | Show the plan and delete nothing. |
--from <storage-url> | Where backups are stored: ./dir, file:///abs, s3://bucket/prefix (default: config). |
--uri <mongodb-uri> | Source whose backups to prune (default: config source.uri, MONGODB_URI). |
--include <pattern> | The selection whose backups to prune (as backed up). Repeatable. |
--exclude <pattern> | The selection whose backups to prune (as backed up). Repeatable. |
--scope-label <key=value> | Prune only backups with this label, instead of the selection's shape. Repeatable. |
--all-sources | Apply the policy to every backup in the storage, whoever wrote it. |
The global options (--config, --json, --quiet,
--verbose, --no-color, --yes) work here too.
Examples
Section titled “Examples”Preview the configured policy:
mongoshield prune --dry-runKeep 7 dailies, 4 weeklies and 12 monthlies, without prompting:
mongoshield prune --daily 7 --weekly 4 --monthly 12 --yesPrune the backups of one selection in a shared bucket:
mongoshield prune --include 'app.orders' --last 24 --from s3://acme-backups/prodPrune the backups labelled team=billing:
mongoshield prune --scope-label team=billing --daily 7Apply one policy to every backup in the storage (asks first):
mongoshield prune --all-sources --daily 7MongoShield is MIT licensed and is not affiliated with, endorsed by or sponsored by MongoDB, Inc. MongoDB is a trademark of MongoDB, Inc.Privacy policy