Apache Geode CHANGELOG

Importing Cache and Region Snapshots

To import a Geode cache or region data snapshot that you previously exported into another cluster or region, use the cache.getSnapshotService.load API, region.getSnapshotService.load API, or the gfsh command-line interface (import data).

Import Requirements

Before you import a region snapshot:

  • Make sure the cache is configured correctly. Configure all registered PdxSerializers, DataSerializers, and Instantiators; create regions; and ensure the classpath contains any required classes.
  • When you import a snapshot containing PDX types, you must wait until the exported type definitions are imported into the cache before inserting data that causes type conflicts. It is recommended that you wait for the import to complete before inserting data.

Import Limitations

During an import, the CacheWriter and CacheListener callbacks are not invoked.

If an error occurs during import, the import is halted and the region will contain some but not all snapshot data.

The state of a cache client is indeterminate after an import. It is likely that the data in the client’s cache is inconsistent with the imported data. Take the client offline during the import and restart it after the import completes.

Importing Cache Snapshots

When you import a cache snapshot, the snapshot file is imported into the same region (match determined by name) that was used during snapshot export. When you import a cache, you import all snapshot files located within a directory into the cache. The API attempts to load all files in the specified directory.

Java API:

File mySnapshotDir = ...
Cache cache = ...

cache.getSnapshotService().load(mySnapshotDir, SnapshotFormat.GEMFIRE);

Importing a Region Snapshot

Java API:

File mySnapshot = ...
Region<String, MyObject> region = ...

region.getSnapshotService().load(mySnapshot, SnapshotFormat.GEMFIRE);

gfsh:

Open a gfsh prompt. After connecting to a Geode cluster, at the prompt type:

gfsh>import data --region=Region --file=FileName.gfd --member=MemberName

where Region corresponds to the name of the region that you want to import data into; FileName (must end in .gfd) corresponds to the name of the file to be imported; and MemberName corresponds to a member that hosts the region. For example:

gfsh>import data --region=region1 --file=region1_2012_10_10.gfd --member=server2

The snapshot file must already reside on the specified member at the location specified in the --file argument before import.

For more information on this command, see import data. For an example of how to invoke this command with additional options, see Export Example with Options.