Skip to content

Error codes

Every MongoShield failure is a MongoShieldError with a stable code. The CLI exits with the code's exit status, so scripts can react to specific failures.

import { isMongoShieldError } from "mongoshield";
try {
await shield.backup();
} catch (error) {
if (isMongoShieldError(error, "MS_STORAGE_FORBIDDEN")) {
// fix credentials
}
}
CodeExitMeaning
MS_CONFIG_INVALID2The configuration is invalid.
MS_CONFIRMATION_REQUIRED3A destructive action needs confirmation, but the session is not interactive. Re-run with --yes.
MS_CONNECTION_FAILED10Could not connect to MongoDB.
MS_AUTH_FAILED11MongoDB rejected the credentials.
MS_PERMISSION_DENIED12The MongoDB user lacks a privilege this operation needs.
MS_UNSUPPORTED_TOPOLOGY13The deployment topology does not support this operation.
MS_SNAPSHOT_TOO_OLD14A snapshot backup took longer than the server keeps snapshot history (5 minutes by default).
MS_CHANGE_HISTORY_LOST15Changes needed for consistency or point-in-time recovery are no longer in the oplog (it rolled over).
MS_STORAGE_NOT_FOUND20The storage location or object does not exist.
MS_STORAGE_FORBIDDEN21Access to the storage location was denied.
MS_STORAGE_IO22A storage read or write failed.
MS_STORAGE_INSUFFICIENT_SPACE23There is not enough space at the storage location.
MS_STORAGE_PRECONDITION_FAILED24A conditional storage write failed because the object already exists.
MS_BACKUP_NOT_FOUND30No backup matches the given selector.
MS_MANIFEST_INVALID31A backup manifest is missing or malformed.
MS_FORMAT_UNSUPPORTED32The backup uses a format version this release cannot read.
MS_INTEGRITY_FAILED33Backup data failed an integrity check (checksum, size or count).
MS_GUARD_FAILED34The backup guard refused a backup that looks like data was lost since the previous one.
MS_BACKUP_PROTECTED35The backup cannot be deleted: it is on hold, under an object lock, or other backups depend on it.
MS_ENCRYPTION_FAILED40Encrypting backup data failed.
MS_DECRYPTION_FAILED41Backup data could not be decrypted or failed authentication.
MS_NO_IDENTITY42The backup is encrypted and no matching identity or passphrase was given.
MS_RESTORE_CONFLICT50The restore target already contains data that would be overwritten.
MS_RESTORE_FAILED51Writing documents to the target failed.
MS_ABORTED60The operation was aborted.
MS_TIMEOUT61The operation timed out.
MS_NOT_IMPLEMENTED70This feature is not implemented yet.
MS_INTERNAL71An unexpected internal error occurred.

MS_CONFIG_INVALID · exit code 2

The configuration is invalid.

MS_CONFIRMATION_REQUIRED · exit code 3

A destructive action needs confirmation, but the session is not interactive. Re-run with --yes.

MS_CONNECTION_FAILED · exit code 10

Could not connect to MongoDB.

MS_AUTH_FAILED · exit code 11

MongoDB rejected the credentials.

MS_PERMISSION_DENIED · exit code 12

The MongoDB user lacks a privilege this operation needs.

MS_UNSUPPORTED_TOPOLOGY · exit code 13

The deployment topology does not support this operation.

MS_SNAPSHOT_TOO_OLD · exit code 14

A snapshot backup took longer than the server keeps snapshot history (5 minutes by default).

MS_CHANGE_HISTORY_LOST · exit code 15

Changes needed for consistency or point-in-time recovery are no longer in the oplog (it rolled over).

MS_STORAGE_NOT_FOUND · exit code 20

The storage location or object does not exist.

MS_STORAGE_FORBIDDEN · exit code 21

Access to the storage location was denied.

MS_STORAGE_IO · exit code 22

A storage read or write failed.

MS_STORAGE_INSUFFICIENT_SPACE · exit code 23

There is not enough space at the storage location.

MS_STORAGE_PRECONDITION_FAILED · exit code 24

A conditional storage write failed because the object already exists.

MS_BACKUP_NOT_FOUND · exit code 30

No backup matches the given selector.

MS_MANIFEST_INVALID · exit code 31

A backup manifest is missing or malformed.

MS_FORMAT_UNSUPPORTED · exit code 32

The backup uses a format version this release cannot read.

MS_INTEGRITY_FAILED · exit code 33

Backup data failed an integrity check (checksum, size or count).

MS_GUARD_FAILED · exit code 34

The backup guard refused a backup that looks like data was lost since the previous one.

MS_BACKUP_PROTECTED · exit code 35

The backup cannot be deleted: it is on hold, under an object lock, or other backups depend on it.

MS_ENCRYPTION_FAILED · exit code 40

Encrypting backup data failed.

MS_DECRYPTION_FAILED · exit code 41

Backup data could not be decrypted or failed authentication.

MS_NO_IDENTITY · exit code 42

The backup is encrypted and no matching identity or passphrase was given.

MS_RESTORE_CONFLICT · exit code 50

The restore target already contains data that would be overwritten.

MS_RESTORE_FAILED · exit code 51

Writing documents to the target failed.

MS_ABORTED · exit code 60

The operation was aborted.

MS_TIMEOUT · exit code 61

The operation timed out.

MS_NOT_IMPLEMENTED · exit code 70

This feature is not implemented yet.

MS_INTERNAL · exit code 71

An unexpected internal error occurred.