On this page



Forces the mongod to flush all pending write operations to disk and locks the entire mongod instance to prevent additional writes until the user releases the lock with the db.fsyncUnlock() command. db.fsyncLock() is an administrative command.

This command provides a simple wrapper around a fsync database command with the following syntax:

{ fsync: 1, lock: true }

This function locks the database and creates a window for backup operations.


Changed in version MongoDB: 3.2

db.fsyncLock() ensures that the data files are safe to copy using low-level backup utilities such as cp, scp, or tar. A mongod started using the copied files contains user-written data that is indistinguishable from the user-written data on the locked mongod.

Prior to MongoDB 3.2, db.fsyncLock() cannot guarantee that WiredTiger data files are safe to copy using low-level backup utilities.

The data files of a locked mongod may change due to operations such as journaling syncs or WiredTiger snapshots. While this has no affect on the logical data (e.g. data accessed by clients), some backup utilities may detect these changes and emit warnings or fail with errors. For more information on MongoDB- recommended backup utilities and procedures, see MongoDB Backup Methods.

Impact on Read Operations

db.fsyncLock() may block reads, including those necessary to verify authentication. Such reads are necessary to establish new connections to a mongod that enforces authorization checks.


When calling db.fsyncLock(), ensure that the connection is kept open to allow a subsequent call to db.fsyncUnlock().

Closing the connection may make it difficult to release the lock.