@Override
  public CliFunctionResult executeFunction(FunctionContext<String[]> context) throws Exception {
    final String[] args = context.getArguments();
    if (args.length < 3) {
      throw new IllegalStateException(
          "Arguments length does not match required length. Export command may have been sent from incompatible older version");
    }
    final String regionName = args[0];
    final String fileName = args[1];
    final boolean parallel = Boolean.parseBoolean(args[2]);
    CliFunctionResult result;

    Cache cache = ((InternalCache) context.getCache()).getCacheForProcessingClientRequests();
    Region<Object, Object> region = cache.getRegion(regionName);
    String hostName = cache.getDistributedSystem().getDistributedMember().getHost();
    if (region != null) {
      RegionSnapshotService<Object, Object> snapshotService = region.getSnapshotService();
      final File exportFile = new File(fileName);
      if (parallel) {
        SnapshotOptions<Object, Object> options = new SnapshotOptionsImpl<>().setParallelMode(true);
        snapshotService.save(exportFile, SnapshotFormat.GEODE, options);
      } else {
        snapshotService.save(exportFile, SnapshotFormat.GEODE);
      }

      String successMessage = CliStrings.format(CliStrings.EXPORT_DATA__SUCCESS__MESSAGE,
          regionName, exportFile.getCanonicalPath(), hostName);
      result = new CliFunctionResult(context.getMemberName(), CliFunctionResult.StatusState.OK,
          successMessage);
    } else {
      result = new CliFunctionResult(context.getMemberName(), CliFunctionResult.StatusState.ERROR,
          CliStrings.format(CliStrings.REGION_NOT_FOUND, regionName));
    }

    return result;
  }
Function which carries out the export of a region to a file on a member. Uses the
RegionSnapshotService to export the data
geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/functions/ExportDataFunction.java