TokuMX Hot Backup – Part 3

Last week I described TokuDB’s new Hot Backup feature. This week we are going to briefly discuss the same feature, but as it was added to TokuMX, our version of MongoDB.

Since the Hot Backup library is essentially a shim between MySQL and the Linux kernel, intercepting file system calls for the life of the process, it should be easy to add this to any other system, including TokuMX. Indeed with our addition of transactions and logging to TokuMX we can gain a consistent backup of any data set at any time.

Unlike MySQL, where system tables use the non-transactional MyISAM storage engine, TokuMX uses internal (non-explicit) transactions for all meta-data changes and regular CRUD operations on BSON data. This keeps the locking fine grained and dramatically improves the performance of large concurrent changes. The side effect is that Hot Backups taken with TokuMX are resilient to massive schema changes. If these changes complete before the backup finishes, they will be represented in the backup copy. If these changes don’t complete in time, they won’t be in the backup copy.

We used the admin command syntax for users to initiate a hot backup and created a plug in architecture where users can send other commands as BSON objects for the purpose of throttling backups and getting error/status updates. The hot backup library is still linked into the TokuMX binary early on, before the backup control plug-in is activated.

To take a backup of a running TokuMX instance, you first have to load the plug in.

Shell

1

db.adminCommand({loadPlugin:'backup_plugin'});

Then you have to use the admin command interface to take a backup. Here we pass the destination directory.

Shell

1

db.adminCommand({backupStart:"/path/to/backup"});

The above command blocks while the backup is in progress. To check the status of the hot backup, or throttle the rate of copying, you simply type these commands from a new prompt:

Shell

1

2

db.adminCommand(“backupStatus”);

db.adminCommand({backupThrottle:26214400});

On top of providing an accurate snapshot of all your TokuMX data for the given server/instance, hot backup can also be used to seed new replicas. Simply take your backup copy of the directory tree to your new server, then use that directory as the starting point for a replica.