Backup and Restore NoSQL Database
This feature is only available in NCache Enterprise Edition.
NCache NoSQL database enables you to store data to a persistence store/database using any of the NoSQL database providers supported by NCache. Keeping in view the need for periodical backup of the persistence store due to maintenance or other reasons, NCache allows to flexibly backup the persistence store while the cache is running. Hence, you can backup your NoSQL data and recover it in case of disasters.
It is important to note that the write operations on the persistence store during backup may result in data corruption. To avoid such corruption, NCache allows you to suspend and resume NCache data persistence. In particular, you can first suspend the data persistence to the persistence store, take the backup of the persistence store and then resume the data persistence to the persistence store in the end.
You should only use suspend and resume NCache data persistence cmdlets when the volume of traffic is low on your NoSQL database. Otherwise, high traffic volume will cause memory issues which will degrade the overall performance of your NoSQL database.
You can easily restore data from the backup by stopping the cache, copying the backup database, and then restarting the cache.
Backup NoSQL Database
The following example demonstrates how to backup persistence store of a NoSQL Database named demoClusteredCache created with NCache Persistence as the NoSQL database provider. For Microsoft SQL Server or MongoDB as NoSQL database providers, you can use native backup tools.
First, stop data writing to the persistence store of demoClusteredCache using
Suspend-NCacheNoSQLDataPersistencecmdlet to avoid possible data corruption as follows.
While your data persistence to the persistence store has been suspended, make sure there is no configuration change (node add/remove or join/leave) that might trigger state transfer on the NoSQL database.
Suspend-NCacheNoSQLDataPersistence -CacheName "demoClusteredCache"
Next, create backup of data. For this, you need to copy all the items from the configured store location (UNC path) of your NoSQL database. You can find the UNC path of the persistence store configured for your NoSQL database under store information in NCache Web Manager. The following PowerShell command copies NCache Persistence database named demoClusteredCache_db from the configured store location to a backup folder.
Copy-Item -Path "\\Fileserver\databases\demoClusteredCache_db" -Destination "F:\NoSQLDatabaseBackup" -Recurse
Once backup is created, resume persisting data to the persistence store of demoClusteredCache using
Resume-NCacheNoSQLDataPersistencecmdlet as follows.
Resume-NCacheNoSQLDataPersistence -CacheName "demoClusteredCache"
Restore NoSQL Database
You can easily restore data from the backup to your NoSQL database anytime. The following example demonstrates how to restore backup data in the persistence store of demoClusteredCache.
Next, you need to copy all the items from your backup folder to the configured store location (UNC path) of your NoSQL database. You can find the UNC path of the persistence store configured for your NoSQL database under store information in NCache Web Manager. You can copy backup from the backup path to the configured store location either manually or using PowerShell. The follwing PowerShell command copies all items from backup folder to the store location of demoClusteredCache.
Copy-Item -Path "F:\NoSQLDatabaseBackup" -Destination "\\Fileserver\databases\demoClusteredCache_db" -Recurse
- Once it is copied, restart demoClusteredCache cache on all server nodes from NCache Web Manager or using Start-Cache PowerShell cmdlet.
NCache provides a sample application on GitHub to bakcup and restore NCache NoSQL Database.