Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
3ed4f4d
PBM-1294 selective logical backup/restore with Users & Roles
rasika-chivate Feb 9, 2026
b6bd051
Update backup-selective.md
rasika-chivate Feb 9, 2026
efec242
Update mkdocs-base.yml
rasika-chivate Feb 9, 2026
f3da6b0
Update backup-selective.md
rasika-chivate Feb 9, 2026
177299b
Update main.html
rasika-chivate Feb 9, 2026
ced7f48
Update backup-selective.md
rasika-chivate Feb 9, 2026
ff13963
Update backup-selective.md
rasika-chivate Feb 9, 2026
8b8dd40
Update backup-selective.md
rasika-chivate Feb 9, 2026
22c1fbf
Update backup-selective.md
rasika-chivate Feb 9, 2026
278ea85
Update backup-selective.md
rasika-chivate Feb 9, 2026
0b3ea71
added use cases
rasika-chivate Feb 9, 2026
4a58295
Update backup-selective.md
rasika-chivate Feb 9, 2026
1a9d6ce
Update backup-selective.md
rasika-chivate Feb 9, 2026
05ca0c5
Update backup-selective.md
rasika-chivate Feb 9, 2026
021bc12
Update backup-selective.md
rasika-chivate Feb 9, 2026
7eaed25
Update backup-selective.md
rasika-chivate Feb 9, 2026
30e165e
Update backup-selective.md
rasika-chivate Feb 9, 2026
ae84767
Update backup-selective.md
rasika-chivate Feb 10, 2026
5647f04
added selective restore section
rasika-chivate Feb 10, 2026
2432b9e
Update restore-selective.md
rasika-chivate Feb 10, 2026
ee82d4b
Update restore-selective.md
rasika-chivate Feb 10, 2026
9320cf0
Update backup-selective.md
rasika-chivate Feb 10, 2026
5d20502
Update backup-selective.md
rasika-chivate Feb 10, 2026
101265e
Update backup-selective.md
rasika-chivate Feb 10, 2026
ba8d71f
Update restore-selective.md
rasika-chivate Feb 10, 2026
b927d60
Update restore-selective.md
rasika-chivate Feb 10, 2026
469d3bf
Update docs/usage/restore-selective.md
rasika-chivate Feb 10, 2026
f54d06e
Update docs/usage/backup-selective.md
rasika-chivate Feb 10, 2026
6efddb8
Update restore-selective.md
rasika-chivate Feb 10, 2026
2389c25
Update backup-selective.md
rasika-chivate Feb 10, 2026
2230e6d
Update restore-selective.md
rasika-chivate Feb 10, 2026
5cad6ca
Update restore-selective.md
rasika-chivate Feb 10, 2026
cc85b24
Update backup-selective.md
rasika-chivate Feb 10, 2026
ccca64c
Update restore-selective.md
rasika-chivate Feb 10, 2026
16e4930
Update restore-selective.md
rasika-chivate Feb 10, 2026
491e4ad
Update restore-selective.md
rasika-chivate Feb 10, 2026
7e8d9ad
Update restore-selective.md
rasika-chivate Feb 10, 2026
56ca7b8
Update restore-selective.md
rasika-chivate Feb 10, 2026
d11d18d
Update restore-selective.md
rasika-chivate Feb 10, 2026
4006d18
Update docs/usage/backup-selective.md
rasika-chivate Feb 11, 2026
1271360
Update restore-selective.md
rasika-chivate Feb 11, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
189 changes: 95 additions & 94 deletions _resourcepdf/overrides/main.html
Original file line number Diff line number Diff line change
@@ -1,103 +1,104 @@
{#
MkDocs template for builds with Material Theme to customize docs layout
by adding marketing-requested elements
#}

{# Import the theme's layout. #}
{% extends "base.html" %}
{# Custom layout extending Material Theme base #}
{% extends "base.html" %}

{% block scripts %}
<script src="https://cmp.osano.com/Azqe5vTyLOSbN3OuT/49ad85b5-0418-4794-ab81-7599dddd534c/osano.js"></script>
{{ super() }}
<script src="https://cmp.osano.com/Azqe5vTyLOSbN3OuT/49ad85b5-0418-4794-ab81-7599dddd534c/osano.js"></script>
{{ super() }}
{% endblock %}

{% block extrahead %}
{{ super() }}
{% set title = config.site_name %}
{% if page and page.meta and page.meta.title %}
{% set title = title ~ " - " ~ page.meta.title %}
{% elif page and page.title and not page.is_homepage %}
{% set title = title ~ " - " ~ page.title %}
{% endif %}
<meta property="og:type" content="website" />
<meta property="og:title" content="{{ title }}" />
<meta property="og:image" content="https://docs.percona.com/percona-backup-mongodb/_images/mongodb.png">
<meta property="og:url" content="https://docs.percona.com/percona-backup-mongodb/">
</head>
<body>
</body>
</html>
{% endblock %}


{% block site_nav %}
{% if nav %}
{% if page.meta and page.meta.hide %}
{% set hidden = "hidden" if "navigation" in page.meta.hide %}
{% endif %}
<div class="md-sidebar md-sidebar--primary" data-md-component="sidebar" data-md-type="navigation" {{ hidden }}>
<div class="md-sidebar__scrollwrap">
<div class="md-sidebar__inner">
{% include "partials/nav.html" %}
<br>
<label class="md-nav__title" for="__drawer">
<a href="https://learn.percona.com/download-percona-backup-for-mongodb-manual-2" onclick="_gaq.push(['b._trackEvent', 'Percona Backup for MongoDB', 'Download', 'Download Manual Backup for MongoDB']);" class="md-nav__link md-nav__link--active" style="font-size: .7rem;">
Download PDF
</a>
</label>
</div>
</div>
</div>
{% endif %}
{% if "toc.integrate" not in features %}
{% if page.meta and page.meta.hide %}
{% set hidden = "hidden" if "toc" in page.meta.hide %}
{% endif %}
<div class="md-sidebar md-sidebar--secondary" data-md-component="sidebar" data-md-type="toc" {{ hidden }}>
<div class="md-sidebar__scrollwrap">
<div class="md-sidebar__inner">
{% include "partials/rating.html" %}
</div>
<div class="md-sidebar__inner">
{% include "partials/edit.html" %}
</div>
<div class="md-sidebar__inner">
{% include "partials/banner.html" %}
</div>
<div class="md-sidebar__inner">
{% include "partials/toc.html" %}
</div>
</div>
</div>
{% endif %}
{% endblock %}
{% block extrahead %}
{{ super() }}
{% set title = config.site_name %}
{% if page and page.meta and page.meta.title %}
{% set title = title ~ " - " ~ page.meta.title %}
{% elif page and page.title and not page.is_homepage %}
{% set title = title ~ " - " ~ page.title %}
{% endif %}
<meta property="og:type" content="website" />
<meta property="og:title" content="{{ title }}" />
<meta property="og:image" content="https://docs.percona.com/percona-backup-mongodb/_images/mongodb.png" />
<meta property="og:url" content="https://docs.percona.com/percona-backup-mongodb/" />
{% endblock %}

{% block content%}
{% block site_nav %}
{% if nav %}
{% if page.meta and page.meta.hide %}
{% set hidden = "hidden" if "navigation" in page.meta.hide %}
{% endif %}
<div class="md-sidebar md-sidebar--primary" data-md-component="sidebar" data-md-type="navigation" {{ hidden|default("") }}>
<div class="md-sidebar__scrollwrap">
<div class="md-sidebar__inner">
{% include "partials/nav.html" %}
<br>
<label class="md-nav__title" for="__drawer">
<a href="https://learn.percona.com/download-percona-backup-for-mongodb-manual-2"
onclick="_gaq.push(['b._trackEvent', 'Percona Backup for MongoDB', 'Download', 'Download Manual Backup for MongoDB']);"
class="md-nav__link md-nav__link--active"
style="font-size: .7rem;">
Download PDF
</a>
</label>
</div>
</div>
</div>
{% endif %}

{{ super() }}
{% if "toc.integrate" not in features %}
{% if page.meta and page.meta.hide %}
{% set hidden = "hidden" if "toc" in page.meta.hide %}
{% endif %}
<div class="md-sidebar md-sidebar--secondary" data-md-component="sidebar" data-md-type="toc" {{ hidden|default("") }}>
<div class="md-sidebar__scrollwrap">
<div class="md-sidebar__inner">
{% include "partials/rating.html" %}
</div>
<div class="md-sidebar__inner">
{% include "partials/edit.html" %}
</div>
<div class="md-sidebar__inner">
{% include "partials/banner.html" %}
</div>
<div class="md-sidebar__inner">
{% include "partials/toc.html" %}
</div>
</div>
</div>
{% endif %}
{% endblock %}

<script>
window.addEventListener('beforeprint', (event) => {
for (const detailEl of document.querySelectorAll('details')) {
if (detailEl.getAttribute('open') == null) {
detailEl.setAttribute('data-was-closed', 'true')
}
detailEl.setAttribute('open', '')
}
})
window.addEventListener('afterprint', (event) => {
for (const detailEl of document.querySelectorAll('details')) {
if (detailEl.getAttribute('data-was-closed') != null) {
detailEl.removeAttribute('data-was-closed')
detailEl.removeAttribute('open')
}
}
})
</script>
{% block content %}
{{ super() }}

<script>
!function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.createElement("script")).type="text/javascript",p.async=!0,p.src=s.api_host+"/static/array.js",(r=t.getElementsByTagName("script")[0]).parentNode.insertBefore(p,r);var u=e;for(void 0!==a?u=e[a]=[]:a="posthog",u.people=u.people||[],u.toString=function(t){var e="posthog";return"posthog"!==a&&(e+="."+a),t||(e+=" (stub)"),e},u.people.toString=function(){return u.toString(1)+".people (stub)"},o="capture identify alias people.set people.set_once set_config register register_once unregister opt_out_capturing has_opted_out_capturing opt_in_capturing reset isFeatureEnabled onFeatureFlags getFeatureFlag getFeatureFlagPayload reloadFeatureFlags group updateEarlyAccessFeatureEnrollment getEarlyAccessFeatures getActiveMatchingSurveys getSurveys onSessionId".split(" "),n=0;n<o.length;n++)g(u,o[n]);e._i.push([i,s,a])},e.__SV=1)}(document,window.posthog||[]);
posthog.init('phc_7unoI9J6Fm0SMrfDp35xNOpCRTkOAibbffQwdGWbHnL',{api_host:'https://eu.posthog.com'})
</script>
<script>
window.addEventListener('beforeprint', () => {
for (const detailEl of document.querySelectorAll('details')) {
if (detailEl.getAttribute('open') == null) {
detailEl.setAttribute('data-was-closed', 'true');
}
detailEl.setAttribute('open', '');
}
});
window.addEventListener('afterprint', () => {
for (const detailEl of document.querySelectorAll('details')) {
if (detailEl.getAttribute('data-was-closed') != null) {
detailEl.removeAttribute('data-was-closed');
detailEl.removeAttribute('open');
}
}
});
</script>

{% endblock %}
<script>
!function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){
function g(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),
t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}
(p=t.createElement("script")).type="text/javascript",p.async=!0,
p.src=s.api_host+"/static/array.js",(r=t.getElementsByTagName("script")[0]).parentNode.insertBefore(p,r);
var u=e;for(void 0!==a?u=e[a]=[]:a="posthog",u.people=u.people||[],
u.toString=function(t){var e="posthog";return"posthog"!==a&&(e+="."+a),t||(e+=" (stub)"),e},
u.people.toString=function(){return u.toString(1)+".people (stub)"},
o="capture identify alias people.set people.set_once set_config register register_once unregister opt_out_capturing has_opted_out_capturing opt_in_capturing reset isFeatureEnabled onFeatureFlags getFeatureFlag getFeatureFlagPayload reloadFeatureFlags group updateEarlyAccessFeatureEnrollment getEarlyAccessFeatures getActiveMatchingSurveys getSurveys onSessionId".split(" "),
n=0;n<o.length;n++)g(u,o[n]);e._i.push([i,s,a])},e.__SV=1)}(document,window.posthog||[]);
posthog.init('phc_7unoI9J6Fm0SMrfDp35xNOpCRTkOAibbffQwdGWbHnL',{api_host:'https://eu.posthog.com'});
</script>
{% endblock %}
44 changes: 44 additions & 0 deletions docs/usage/backup-selective.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,50 @@

Multi-format is the default data format for both full and selective backups since it allows selective restore. Note, however, that you can make only full restores from backups made with earlier versions of Percona Backup for MongoDB.

## Selective backup with users and roles

### Overview

Percona Backup for MongoDB enables you to perform selective backups of databases and collections. Also, you can choose to include **users and roles defined** in the database in your selective backup, ensuring that access control is restored along with the data.

To back up a specific namespace and include users and roles, run the following command:

Check warning on line 35 in docs/usage/backup-selective.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/usage/backup-selective.md#L35

[Vale.Spelling] Did you really mean 'namespace'?
Raw output
{"message": "[Vale.Spelling] Did you really mean 'namespace'?", "location": {"path": "docs/usage/backup-selective.md", "range": {"start": {"line": 35, "column": 23}}}, "severity": "WARNING"}
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The restore page documents important constraints for --with-users-and-roles (e.g., requiring a collection wildcard like mydb.*, excluding cluster/global users/roles, and overwrite behavior on restore). This backup page currently doesn’t call out the wildcard requirement or explicitly clarify the same scope limitation (db-scoped only). Suggest adding a short warning/note here for consistency so users don’t try --ns=\"db.collection\" or assume cluster-wide users/roles are included.

Copilot uses AI. Check for mistakes.


```sh
pbm backup --ns="mydb.*" --with-users-and-roles
```

where:

`--ns="mydb.*"` **→** specifies the namespace (all collections in `mydb`).

Check warning on line 44 in docs/usage/backup-selective.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/usage/backup-selective.md#L44

[Vale.Spelling] Did you really mean 'namespace'?
Raw output
{"message": "[Vale.Spelling] Did you really mean 'namespace'?", "location": {"path": "docs/usage/backup-selective.md", "range": {"start": {"line": 44, "column": 37}}}, "severity": "WARNING"}

`--with-users-and-roles` **→** includes all users and custom roles defined in `mydb` in the backup.

??? info "What happens under the hood?"
- Percona Backup for MongoDB captures all collections within `mydb`.
- Percona Backup for MongoDB filters the users and roles for entities where the `db` field matches `mydb`.
- Global administrative roles or users defined in other databases are excluded.


**Example**

```sh
pbm backup --ns="invoices.*" --with-users-and-roles
```

This command backs up all collections in the **invoices** database, along with its users and roles.

### Use cases

=== "Partial migration of a database"
As applications scale, migrating a specific database from a shared cluster to a dedicated cluster becomes necessary. Using the `--with-users-and-roles` flag ensures that the destination cluster inherits the application-specific users and custom roles immediately, thereby preventing errors post-migration.

Check warning on line 65 in docs/usage/backup-selective.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/usage/backup-selective.md#L65

[Google.WordList] Use 'app' instead of 'application'.
Raw output
{"message": "[Google.WordList] Use 'app' instead of 'application'.", "location": {"path": "docs/usage/backup-selective.md", "range": {"start": {"line": 65, "column": 212}}}, "severity": "WARNING"}


=== "Staging environment"
To reproduce production issues or validate security patches, you need a staging environment that mirrors production exactly.

By backing up `mydb` together with its users and roles, the copy reflects not only the data but also the access-control model. This enables accurate reproduction of permission-related behavior such as read/write restrictions, role grants, and user privileges.


## Next steps

Expand Down
56 changes: 56 additions & 0 deletions docs/usage/restore-selective.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,62 @@
pbm restore <backup_name> --ns <database.*> --with-users-and-roles
```

### Selective restore with users and roles

#### Overview

Percona Backup for MongoDB allows you to perform selective restore of databases and collections. Additionally, you can choose to include **users and roles defined** in the database in your selective backup, ensuring that access control is restored along with the data.
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is in the restore section, but it says 'include ... in your selective backup'. Suggest rewording to 'include ... in your selective restore' (or 'restore users and roles alongside the data') to avoid confusion.

Suggested change
Percona Backup for MongoDB allows you to perform selective restore of databases and collections. Additionally, you can choose to include **users and roles defined** in the database in your selective backup, ensuring that access control is restored along with the data.
Percona Backup for MongoDB allows you to perform selective restore of databases and collections. Additionally, you can choose to include **users and roles defined** in the database in your selective restore, ensuring that access control is restored along with the data.

Copilot uses AI. Check for mistakes.

!!! warning
- The `--with-users-and-roles` flag applies only to users and roles defined within the database being backed up or restored. Global users and roles defined at the cluster level **are not included**.
- If applications rely on roles or privileges that span multiple databases, a selective restore of a single database may not fully reestablish access control. Always verify dependencies before restore.
- Restoring users and roles will overwrite existing definitions in the target database. Review current role configurations before restore to avoid accidental loss of custom changes.

Check warning on line 44 in docs/usage/restore-selective.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/usage/restore-selective.md#L44

[Google.Will] Avoid using 'will'.
Raw output
{"message": "[Google.Will] Avoid using 'will'.", "location": {"path": "docs/usage/restore-selective.md", "range": {"start": {"line": 44, "column": 33}}}, "severity": "WARNING"}

To restore a specific namespace and include users and roles, run the following command:

Check warning on line 46 in docs/usage/restore-selective.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/usage/restore-selective.md#L46

[Vale.Spelling] Did you really mean 'namespace'?
Raw output
{"message": "[Vale.Spelling] Did you really mean 'namespace'?", "location": {"path": "docs/usage/restore-selective.md", "range": {"start": {"line": 46, "column": 23}}}, "severity": "WARNING"}

```sh
pbm restore --ns="mydb.*" --with-users-and-roles <backup-name>
```

where:

`--ns="mydb.*"` **→** Restores only the collections belonging to mydb.

Check warning on line 54 in docs/usage/restore-selective.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/usage/restore-selective.md#L54

[Vale.Spelling] Did you really mean 'mydb'?
Raw output
{"message": "[Vale.Spelling] Did you really mean 'mydb'?", "location": {"path": "docs/usage/restore-selective.md", "range": {"start": {"line": 54, "column": 8}}}, "severity": "WARNING"}

`--with-users-and-roles` → Restores the database-defined users and roles alongside the data.

`<backup-name>` **→** The identifier of the backup to restore from (as shown in Percona Backup for MongoDB backup listings and logs).

**Namespace requirements**

Check warning on line 60 in docs/usage/restore-selective.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/usage/restore-selective.md#L60

[Vale.Spelling] Did you really mean 'Namespace'?
Raw output
{"message": "[Vale.Spelling] Did you really mean 'Namespace'?", "location": {"path": "docs/usage/restore-selective.md", "range": {"start": {"line": 60, "column": 3}}}, "severity": "WARNING"}

The `--with-users-and-roles` flag requires a collection wildcard in the namespace.

Check warning on line 62 in docs/usage/restore-selective.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/usage/restore-selective.md#L62

[Vale.Spelling] Did you really mean 'namespace'?
Raw output
{"message": "[Vale.Spelling] Did you really mean 'namespace'?", "location": {"path": "docs/usage/restore-selective.md", "range": {"start": {"line": 62, "column": 73}}}, "severity": "WARNING"}

For example, `--ns="test.*"` is valid, but `--ns="test.col"` is not valid.

Use `--with-users-and-roles` only with selective restore (i.e., when you specify `--ns`). If you are not using `--ns`, you are not performing a selective restore, and this option is not required.

Check failure on line 66 in docs/usage/restore-selective.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/usage/restore-selective.md#L66

[Google.Latin] Use 'that is' instead of 'i.e.'.
Raw output
{"message": "[Google.Latin] Use 'that is' instead of 'i.e.'.", "location": {"path": "docs/usage/restore-selective.md", "range": {"start": {"line": 66, "column": 59}}}, "severity": "ERROR"}

??? info "What happens under the hood?"
- Percona Backup for MongoDB restores the selected collections within `mydb` from the specified backup.
- Percona Backup for MongoDB restores roles where the db field matches `mydb`.
- Percona Backup for MongoDB restores users where the db field matches `mydb`, including their role assignments within `mydb`.

**Example**

```sh
pbm restore --ns="invoices.*" --with-users-and-roles 2025-03-10T10:44:52Z
```

This command restores all collections in the `invoices` database, along with the users and roles defined in `invoices`, from the backup `2025-03-10T10:44:52Z`.

#### Use cases

=== "Partial restore after data loss"
A service using `mydb` experienced accidental deletes or corruption, while other databases in the cluster remain unaffected. Selective restore limits recovery to only the required database.

=== "Roll back access control changes"
A recent modification to custom roles in `mydb` introduced permission failures. Applications that rely on those roles can no longer perform required operations.

To ensure complete recovery, you need to restore not only the data but also the users and roles tied to the database’s access controls.

### Restore a collection under a different name

You can restore a specific collection under a different name alongside the current collection. This is useful when you troubleshoot database issues and need to compare the data in both collections to identify the root of the issue.
Expand Down
2 changes: 1 addition & 1 deletion mkdocs-base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ site_name: Percona Backup for MongoDB
site_description: documentation
site_author: Percona LLC
copyright: >
<a href="https://www.percona.com/about">Percona LLC</a> and/or its affiliates © 2025
<a href="https://www.percona.com/about">Percona LLC</a> and/or its affiliates © 2026
— <a href="#" onclick="Osano.cm.showDrawer('osano-cm-dom-info-dialog-open')">Cookie Preferences</a>
repo_name: percona/pbm-docs
repo_url: https://github.com/percona/pbm-docs
Expand Down