---
title: Charmhub | Deploy MongoDB using Charmhub - The Open Operator Collection
description: Deploy the latest version of MongoDB on any cloud.
url: https://charmhub.io/mongodb/libraries/mongodb_backups
---

# MongoDB

[Canonical](https://charmhub.io/publisher/data-platform "View all packages from Canonical")

* [Canonical](https://charmhub.io/publisher/data-platform "View all packages from Canonical")
* [Databases](https://charmhub.io/?filter=databases)

Platform:

24.04

22.04

6/stable 265

```
juju deploy mongodb --channel 6/stable
```

[Learn to deploy on juju >](https://juju.is/docs/juju/manage-applications)

[Toggle side navigation](https://charmhub.io/mongodb/libraries/mongodb_backups#drawer)

## charms.mongodb.v1.mongodb\_backups

* [*Docstrings*Docstrings](https://charmhub.io/mongodb/libraries/mongodb_backups)
  [*Code*Source code](https://charmhub.io/mongodb/libraries/mongodb_backups/source-code)
* + Download

    Fetch library

    ```
    charmcraft fetch-lib charms.mongodb.v1.mongodb_backups
    ```

    [Download mongodb\_backups.py](https://charmhub.io/mongodb/libraries/mongodb_backups/download)
  + *Last updated* 12 Nov 2024
  + *Revision* Library version 1.5

In this class, we manage backup configurations and actions.

Specifically backups are handled with Percona Backup MongoDB (pbm).
A user for PBM is created when MongoDB is first started during the start phase.
This user is named "backup".

---

Index

* [class ResyncError](https://charmhub.io/mongodb/libraries/mongodb_backups#resyncerror)
* [class SetPBMConfigError](https://charmhub.io/mongodb/libraries/mongodb_backups#setpbmconfigerror)
* [class PBMBusyError](https://charmhub.io/mongodb/libraries/mongodb_backups#pbmbusyerror)
* [class RestoreError](https://charmhub.io/mongodb/libraries/mongodb_backups#restoreerror)
* [class BackupError](https://charmhub.io/mongodb/libraries/mongodb_backups#backuperror)
* [class MongoDBBackups](https://charmhub.io/mongodb/libraries/mongodb_backups#mongodbbackups)
* + [def \_\_init\_\_(
    self,
    charm)](https://charmhub.io/mongodb/libraries/mongodb_backups#mongodbbackups-__init__)
* + [def on\_s3\_relation\_joined(
    self,
    event)](https://charmhub.io/mongodb/libraries/mongodb_backups#mongodbbackups-on_s3_relation_joined)
* + [def is\_valid\_s3\_integration(
    self)](https://charmhub.io/mongodb/libraries/mongodb_backups#mongodbbackups-is_valid_s3_integration)
* + [def get\_pbm\_status(
    self)](https://charmhub.io/mongodb/libraries/mongodb_backups#mongodbbackups-get_pbm_status)
* + [def retrieve\_error\_message(
    self,
    pbm\_status)](https://charmhub.io/mongodb/libraries/mongodb_backups#mongodbbackups-retrieve_error_message)
* + [def process\_pbm\_error(
    self,
    pbm\_status)](https://charmhub.io/mongodb/libraries/mongodb_backups#mongodbbackups-process_pbm_error)
* + [def get\_backup\_error\_status(
    self,
    backup\_id)](https://charmhub.io/mongodb/libraries/mongodb_backups#mongodbbackups-get_backup_error_status)

#### class ResyncError

Description

Raised when pbm is resyncing configurations and is not ready to be used. None

#### class SetPBMConfigError

Description

Raised when pbm cannot configure a given option. None

#### class PBMBusyError

Description

Raised when PBM is busy and cannot run another operation. None

#### class RestoreError

Description

Raised when backup operation is failed. None

#### class BackupError

Description

Raised when backup operation is failed. None

#### class MongoDBBackups

Description

Manages MongoDB backups. None

Methods

MongoDBBackups.
\_\_init\_\_(

*self*

,
charm
)

Description

Manager of MongoDB client relations. None

MongoDBBackups.
on\_s3\_relation\_joined(

*self*

,
event: RelationJoinedEvent
)

Description

Checks for valid integration for s3-integrations. None

MongoDBBackups.
is\_valid\_s3\_integration(

*self*
)

Return true if relation to s3-integrator is valid.

Description

Only replica sets and config servers can integrate to s3-integrator.

MongoDBBackups.
get\_pbm\_status(

*self*
)

Description

Retrieve pbm status. None

MongoDBBackups.
retrieve\_error\_message(

*self*

,
pbm\_status: Dict
)

Parses pbm status for an error message from the current unit.

Description

If pbm\_agent is in the error state, the command `pbm status` does not raise an error.
Instead, it is in the log messages. pbm\_agent also shows all the error messages for other
replicas in the set.

MongoDBBackups.
process\_pbm\_error(

*self*

,
pbm\_status
)

Description

Returns errors found in PBM status. None

MongoDBBackups.
get\_backup\_error\_status(

*self*

,
backup\_id: str
)

Description

Get the error status for a provided backup. None
