private long copyData(final Context context, final Path inputPath, final InputStream in,
      final Path outputPath, final FSDataOutputStream out, final long inputFileSize)
      throws IOException {
      final String statusMessage =
        "copied %s/" + Strings.humanReadableInt(inputFileSize) + " (%.1f%%)";

      try {
        byte[] buffer = new byte[bufferSize];
        long totalBytesWritten = 0;
        int reportBytes = 0;
        int bytesRead;

        while ((bytesRead = in.read(buffer)) > 0) {
          out.write(buffer, 0, bytesRead);
          totalBytesWritten += bytesRead;
          reportBytes += bytesRead;

          if (reportBytes >= reportSize) {
            context.getCounter(Counter.BYTES_COPIED).increment(reportBytes);
            context
              .setStatus(String.format(statusMessage, Strings.humanReadableInt(totalBytesWritten),
                (totalBytesWritten / (float) inputFileSize) * 100.0f) + " from " + inputPath
                + " to " + outputPath);
            reportBytes = 0;
          }
        }

        context.getCounter(Counter.BYTES_COPIED).increment(reportBytes);
        context.setStatus(String.format(statusMessage, Strings.humanReadableInt(totalBytesWritten),
          (totalBytesWritten / (float) inputFileSize) * 100.0f) + " from " + inputPath + " to "
          + outputPath);

        return totalBytesWritten;
      } finally {
        out.close();
        in.close();
      }
    }
Try to Preserve the files attribute selected by the user copying them from the source file
This is only required when you are exporting as a different user than "hbase" or on a system
that doesn't have the "hbase" user. This is not considered a blocking failure since the user
can force a chmod with the user that knows is available on the system.
hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/snapshot/ExportSnapshot.java