diff --git a/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/mapreduce/MapReduceBackupCopyJob.java b/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/mapreduce/MapReduceBackupCopyJob.java index 3cc8bcf..56e9c53 100644 --- a/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/mapreduce/MapReduceBackupCopyJob.java +++ b/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/mapreduce/MapReduceBackupCopyJob.java @@ -332,10 +332,11 @@ public class MapReduceBackupCopyJob implements BackupCopyJob { int level = conf.getInt(NUMBER_OF_LEVELS_TO_PRESERVE_KEY, 1); int count = 0; String relPath = ""; - while (count++ < level) { + while (count++ < level && path != null) { relPath = Path.SEPARATOR + path.getName() + relPath; path = path.getParent(); } + LOG.debug("key for " + path + " is " + relPath); return new Text(relPath); } @@ -398,14 +399,23 @@ public class MapReduceBackupCopyJob implements BackupCopyJob { // We need to create the target dir before run distcp. LOG.debug("DistCp options: " + Arrays.toString(options)); Path dest = new Path(options[options.length - 1]); - String[] newOptions = new String[options.length + 1]; - System.arraycopy(options, 0, newOptions, 1, options.length); - newOptions[0] = "-async"; // run DisCp in async mode FileSystem destfs = dest.getFileSystem(conf); if (!destfs.exists(dest)) { destfs.mkdirs(dest); } - res = distcp.run(newOptions); + String[] newOptions = new String[3]; + System.arraycopy(options, options.length - 1, newOptions, 2, 1); + newOptions[0] = "-async"; // run DisCp in async mode + for (int i = 0; i < options.length; i++) { + // there are more than one source path to be copied + // copy each source alone + System.arraycopy(options, i, newOptions, 1, 1); + res = distcp.run(newOptions); + if (res != 0) { + LOG.debug("Failed copying " + options[i] + " result=" + res); + return res; + } + } } return res;