diff --git a/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/snapshot/ExportSnapshot.java b/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/snapshot/ExportSnapshot.java index ef67b7b..ec604f9 100644 --- a/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/snapshot/ExportSnapshot.java +++ b/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/snapshot/ExportSnapshot.java @@ -1001,23 +1001,32 @@ public class ExportSnapshot extends AbstractHBaseTool implements Tool { // Step 1 - Copy fs1:/.snapshot/ to fs2:/.snapshot/.tmp/ // The snapshot references must be copied before the hfiles otherwise the cleaner // will remove them because they are unreferenced. + boolean copySucceeded = false; try { - LOG.info("Copy Snapshot Manifest"); - FileUtil.copy(inputFs, snapshotDir, outputFs, initialOutputSnapshotDir, false, false, conf); + LOG.info("Copy Snapshot Manifest from " + snapshotDir + " to " + initialOutputSnapshotDir); + boolean ret = FileUtil.copy(inputFs, snapshotDir, outputFs, initialOutputSnapshotDir, false, + false, conf); + if (!ret) { + throw new IOException("Snapshot Manifest failed from " + snapshotDir + " to " + + initialOutputSnapshotDir); + } + copySucceeded = true; } catch (IOException e) { throw new ExportSnapshotException("Failed to copy the snapshot directory: from=" + snapshotDir + " to=" + initialOutputSnapshotDir, e); } finally { - if (filesUser != null || filesGroup != null) { - LOG.warn((filesUser == null ? "" : "Change the owner of " + needSetOwnerDir + " to " - + filesUser) - + (filesGroup == null ? "" : ", Change the group of " + needSetOwnerDir + " to " - + filesGroup)); - setOwner(outputFs, needSetOwnerDir, filesUser, filesGroup, true); - } - if (filesMode > 0) { - LOG.warn("Change the permission of " + needSetOwnerDir + " to " + filesMode); - setPermission(outputFs, needSetOwnerDir, (short)filesMode, true); + if (copySucceeded) { + if (filesUser != null || filesGroup != null) { + LOG.warn((filesUser == null ? "" : "Change the owner of " + needSetOwnerDir + " to " + + filesUser) + + (filesGroup == null ? "" : ", Change the group of " + needSetOwnerDir + " to " + + filesGroup)); + setOwner(outputFs, needSetOwnerDir, filesUser, filesGroup, true); + } + if (filesMode > 0) { + LOG.warn("Change the permission of " + needSetOwnerDir + " to " + filesMode); + setPermission(outputFs, needSetOwnerDir, (short)filesMode, true); + } } }