Thursday , June 13 2024

Back Up a Sharded Cluster with File System Snapshots


In MongoDB we can take backups with database dumps or filesystem snapshots. In large databases it is recommended to use file system snapshots rather than dump backups. Any file system snapshot tool can be used as LVM snapshots. In our system LVM can be used.

The process is given bleow:


Step 1: Disable the balancer.

connect to the mongos session:


Step 2: Start LVM snapshot for data files directory

I have db files in /db directory which has the filesystem : /dev/mapper/dbvg-dblv


So I need to create the lvm sbapshot of /dev/mapper/dbvg-dblv


Step 3: take backup to another directory

The snapshot file is created. But the backup process is not finished. We need to take the backup to another storage. So first we need to unmount the snap.


Then we can zip the snap file and copy it to another directory. So we can use it if anything happens to the datafile directory.


Step 4: Reenable the balancer

connect to the mongos session:


About Selcen Sahin

Leave a Reply

Your email address will not be published. Required fields are marked *