Make a selective logical backup¶
Before you start¶
- Install and set up Percona Backup for MongoDB
- Check that
pbm agent
is running with thepbm status
command -
Check that all
pbm-agents
and PBM CLI have the same version. Otherwise we cannot guarantee successful backups and data consistency in them.To check the version, run the following commands:
pbm status
to check the version of pbm-agentspbm version
to check the version of PBM CLI.
Procedure¶
Version added: 2.0.0
Before you start, read about selective backups known limitations.
To make a selective backup, run the pbm backup
command and provide the value for the --ns
flag in the format <database.collection>
. The --ns
flag value is case sensitive. For example, to back up the “Payments” collection, run the following command:
$ pbm backup --ns=customers.payments
To back up the “Invoices” database and all collections that it includes, run the pbm backup
command as follows:
$ pbm backup --ns=invoices.*
To back up multiple namespaces, specify them as a comma-separated list for the --ns
flag: <db1.col1>
,<db2.*>
,<db3.collX>
. The number of namespaces to specify is unlimited.
During the backup process, Percona Backup for MongoDB stores data in the new multi-file format where each collection has a separate file. The oplog is stored for all namespaces regardless whether this is a full or selective backup.
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.
Next steps¶
Useful links¶
Created: April 11, 2025