Exporting Cache and Region Snapshots
To save Geode cache or region data to a snapshot that you can later load into another distributed system or region, use the
region.getSnapshotService.save API, or the
gfsh command-line interface (
If an error occurs during export, the export halts and the snapshot operation is canceled. Typical errors that halt an export include scenarios such as full disk, problems with file permissions, and network partitioning.
When you export an entire cache, it exports all regions in the cache as individual snapshot files into a directory. If no directory is specified, the default is the current directory. A snapshot file is created for each region, and the export operation automatically names each snapshot filename using the following convention:
When the export operation writes the snapshot filename, it replaces each forward slash (’/’) in the region path with a dash (’-’).
Using Java API:
File mySnapshotDir = ... Cache cache = ... cache.getSnapshotService().save(mySnapshotDir, SnapshotFormat.GEMFIRE);
Optionally, you can set a filter on the snapshot entries during the export. See Filtering Entries During Import or Export for an example.
You can also export a specific region using the following API or gfsh command:
File mySnapshot = ... Region<String, MyObject> region = ... region.getSnapshotService().save(mySnapshot, SnapshotFormat.GEMFIRE);
Open a gfsh prompt. After connecting to a Geode distributed system, at the prompt type:
gfsh>export data --region=Region --file=filename.gfd --member=membername
where Region corresponds to the name of the region that you want to export, filename (must end in .gfd) corresponds to the name of the export file and membername corresponds to a member where the region to export is hosted. For example:
gfsh>export data --region=region1 --file=region1_2012_10_10.gfd --member=server1
The snapshot file will be written on the remote member at the location specified by the
--file argument. For example, in the example command above, the
region1_2012_10_10.gfd file will be written in the working directory of
server1. For more information on this command, see export data.