Import/Export Cache Data
NCache provides users with the ability to backup cache data for later use. To create the backup use the Export Cache Data PowerShell cmdlet. Once data is exported, you can get all the items present in the existing backup of the cache using the Import Cache Data PowerShell cmdlet.
It is important to note that, you can only restore data for a distributed cache using the Import and Export cache data cmdlets together. This is particularly useful during an NCache version upgrade when restoring previously cached data is required.
Important
The cache name must be the same while using the Export-CacheData and Import-CacheData cmdlets.
Export Cache Data
The Export-CacheData cmdlet enables the user to create a backup of the data present in the cache for later use.
- This command backs up all the keys present in the cache.
Export-CacheData -Name demoCache -Path C:\Backup-path
- This command backs up all the keys present in the cache with 2 MB data files.
Export-CacheData -Name demoCache -Path C:\Backup-path \
-FileSize 2
- This command backs up all the keys present in the cache on server 20.200.20.40.
Export-CacheData -Name demoCache -Path C:\Backup-path \
-Server 20.200.20.40
- This command backs up all the keys present in the cache, using security credentials.
Export-CacheData -Name demoCache -Path C:\Backup-path \
-Credentials(Get-Credential john_smith)
Import Cache Data
You can use the Import-CacheData cmdlet to restore the data that was backed up using the Export-CacheData command.
- This command reloads all the items to the cache from the specified path.
Import-CacheData -Name demoCache -Path C:\Backup-path
- This command reloads all the items to the cache from the specified path and will exit if 10 errors occur during the process.
Import-CacheData -Name demoCache -Path C:\Backup-path \
–ErrorThreshhold 10
- This command reloads all the items in bulk of 100 to the cache from the specified path.
Import-CacheData -Name demoCache -Path C:\Backup-path \
-BulkSize 100
- This command reloads all the items to the cache on server 20.200.20.40 from the specified path.
Import-CacheData -Name demoCache -Path C:\Backup-path \
-Server 20.200.20.40
- This command reloads all the items to the cache from the specified path, using security credentials.
Import-CacheData -Name demoCache -Path C:\Backup-path \
-Credentials(Get-Credential john_smith)
See Also
Start Cache
Restart Cache
Manage Cache Service on a Server Node