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 }}| Code | Exit | Meaning |
|---|---|---|
MS_CONFIG_INVALID | 2 | The configuration is invalid. |
MS_CONFIRMATION_REQUIRED | 3 | A destructive action needs confirmation, but the session is not interactive. Re-run with --yes. |
MS_CONNECTION_FAILED | 10 | Could not connect to MongoDB. |
MS_AUTH_FAILED | 11 | MongoDB rejected the credentials. |
MS_PERMISSION_DENIED | 12 | The MongoDB user lacks a privilege this operation needs. |
MS_UNSUPPORTED_TOPOLOGY | 13 | The deployment topology does not support this operation. |
MS_SNAPSHOT_TOO_OLD | 14 | A snapshot backup took longer than the server keeps snapshot history (5 minutes by default). |
MS_CHANGE_HISTORY_LOST | 15 | Changes needed for consistency or point-in-time recovery are no longer in the oplog (it rolled over). |
MS_STORAGE_NOT_FOUND | 20 | The storage location or object does not exist. |
MS_STORAGE_FORBIDDEN | 21 | Access to the storage location was denied. |
MS_STORAGE_IO | 22 | A storage read or write failed. |
MS_STORAGE_INSUFFICIENT_SPACE | 23 | There is not enough space at the storage location. |
MS_STORAGE_PRECONDITION_FAILED | 24 | A conditional storage write failed because the object already exists. |
MS_BACKUP_NOT_FOUND | 30 | No backup matches the given selector. |
MS_MANIFEST_INVALID | 31 | A backup manifest is missing or malformed. |
MS_FORMAT_UNSUPPORTED | 32 | The backup uses a format version this release cannot read. |
MS_INTEGRITY_FAILED | 33 | Backup data failed an integrity check (checksum, size or count). |
MS_GUARD_FAILED | 34 | The backup guard refused a backup that looks like data was lost since the previous one. |
MS_BACKUP_PROTECTED | 35 | The backup cannot be deleted: it is on hold, under an object lock, or other backups depend on it. |
MS_ENCRYPTION_FAILED | 40 | Encrypting backup data failed. |
MS_DECRYPTION_FAILED | 41 | Backup data could not be decrypted or failed authentication. |
MS_NO_IDENTITY | 42 | The backup is encrypted and no matching identity or passphrase was given. |
MS_RESTORE_CONFLICT | 50 | The restore target already contains data that would be overwritten. |
MS_RESTORE_FAILED | 51 | Writing documents to the target failed. |
MS_ABORTED | 60 | The operation was aborted. |
MS_TIMEOUT | 61 | The operation timed out. |
MS_NOT_IMPLEMENTED | 70 | This feature is not implemented yet. |
MS_INTERNAL | 71 | An unexpected internal error occurred. |
ms_config_invalid
Section titled “ms_config_invalid”MS_CONFIG_INVALID · exit code 2
The configuration is invalid.
ms_confirmation_required
Section titled “ms_confirmation_required”MS_CONFIRMATION_REQUIRED · exit code 3
A destructive action needs confirmation, but the session is not interactive. Re-run with --yes.
ms_connection_failed
Section titled “ms_connection_failed”MS_CONNECTION_FAILED · exit code 10
Could not connect to MongoDB.
ms_auth_failed
Section titled “ms_auth_failed”MS_AUTH_FAILED · exit code 11
MongoDB rejected the credentials.
ms_permission_denied
Section titled “ms_permission_denied”MS_PERMISSION_DENIED · exit code 12
The MongoDB user lacks a privilege this operation needs.
ms_unsupported_topology
Section titled “ms_unsupported_topology”MS_UNSUPPORTED_TOPOLOGY · exit code 13
The deployment topology does not support this operation.
ms_snapshot_too_old
Section titled “ms_snapshot_too_old”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
Section titled “ms_change_history_lost”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
Section titled “ms_storage_not_found”MS_STORAGE_NOT_FOUND · exit code 20
The storage location or object does not exist.
ms_storage_forbidden
Section titled “ms_storage_forbidden”MS_STORAGE_FORBIDDEN · exit code 21
Access to the storage location was denied.
ms_storage_io
Section titled “ms_storage_io”MS_STORAGE_IO · exit code 22
A storage read or write failed.
ms_storage_insufficient_space
Section titled “ms_storage_insufficient_space”MS_STORAGE_INSUFFICIENT_SPACE · exit code 23
There is not enough space at the storage location.
ms_storage_precondition_failed
Section titled “ms_storage_precondition_failed”MS_STORAGE_PRECONDITION_FAILED · exit code 24
A conditional storage write failed because the object already exists.
ms_backup_not_found
Section titled “ms_backup_not_found”MS_BACKUP_NOT_FOUND · exit code 30
No backup matches the given selector.
ms_manifest_invalid
Section titled “ms_manifest_invalid”MS_MANIFEST_INVALID · exit code 31
A backup manifest is missing or malformed.
ms_format_unsupported
Section titled “ms_format_unsupported”MS_FORMAT_UNSUPPORTED · exit code 32
The backup uses a format version this release cannot read.
ms_integrity_failed
Section titled “ms_integrity_failed”MS_INTEGRITY_FAILED · exit code 33
Backup data failed an integrity check (checksum, size or count).
ms_guard_failed
Section titled “ms_guard_failed”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
Section titled “ms_backup_protected”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
Section titled “ms_encryption_failed”MS_ENCRYPTION_FAILED · exit code 40
Encrypting backup data failed.
ms_decryption_failed
Section titled “ms_decryption_failed”MS_DECRYPTION_FAILED · exit code 41
Backup data could not be decrypted or failed authentication.
ms_no_identity
Section titled “ms_no_identity”MS_NO_IDENTITY · exit code 42
The backup is encrypted and no matching identity or passphrase was given.
ms_restore_conflict
Section titled “ms_restore_conflict”MS_RESTORE_CONFLICT · exit code 50
The restore target already contains data that would be overwritten.
ms_restore_failed
Section titled “ms_restore_failed”MS_RESTORE_FAILED · exit code 51
Writing documents to the target failed.
ms_aborted
Section titled “ms_aborted”MS_ABORTED · exit code 60
The operation was aborted.
ms_timeout
Section titled “ms_timeout”MS_TIMEOUT · exit code 61
The operation timed out.
ms_not_implemented
Section titled “ms_not_implemented”MS_NOT_IMPLEMENTED · exit code 70
This feature is not implemented yet.
ms_internal
Section titled “ms_internal”MS_INTERNAL · exit code 71
An unexpected internal error occurred.
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