Percona Backup for MongoDB Intro¶
How to use Percona Backup for MongoDB: going back in time (
Even in a highly-available architecture, such as with MongoDB replication, backups are still required even though losing one server is not fatal. Whether for a complete or partial data disaster you can use PBM (Percona Backup for MongoDB) to go back in time to the best available backup snapshot.
For example, imagine your web application’s update was released on Sunday, June 9th 23:00 EDT but, by 11:23 Monday, someone realizes that the update has a bug that is wiping the historical data of any user who logged in. Nobody likes to have downtime, but it’s time to roll back: what’s the best backup to use?
$ pbm list --mongodb-uri="mongodb://pbmuser:secretpwd@mongocsvr1:27018,mongocsvr2:27018,mongocsvr3:27018/?replicaSet=configrs"
$ pbm list 2019-09-10T07:04:14Z 2019-09-09T07:03:50Z 2019-09-08T07:04:21Z 2019-09-07T07:04:18Z
The most recent daily backup is 03:04 EDT (07:04 UTC), which would include 4 hours of damage caused by the bug. Let’s restore the one before that:
$ pbm restore 2019-06-09T07:03:50Z --mongodb-uri="mongodb://pbmuser:secretpwd@mongocsvr1:27018,mongocsvr2:27018,mongocsvr3:27018/?replicaSet=configrs"
Next time there is an application release, it might be best to make an extra backup manually just before:
$ pbm backup --mongodb-uri="mongodb://pbmuser:secretpwd@mongocsvr1:27018,mongocsvr2:27018,mongocsvr3:27018/?replicaSet=configrs"
Percona Backup for MongoDB is an uncomplicated command-line tool by design. The full set of commands:
$ pbm help usage: pbm [<flags>] <command> [<args> ...] Percona Backup for MongoDB Flags: --help Show context-sensitive help (also try --help-long and --help-man). --mongodb-uri=MONGODB-URI MongoDB connection string. Default value read from environment variable PBM_MONGODB_URI. Commands: help [<command>...] Show help. config [<flags>] Set, change or list the config backup Make backup restore <backup_name> Restore backup delete-backup <backup_name> [<flags>] Delete backup(s) cancel-backup Cancel backup list [<flags>] Backup list version [<flags>] PBM version info