Source:
protected AlluxioURI takeBackup(BackupPRequest request, AtomicLong entryCounter) throws IOException { AlluxioURI backupUri; try (CloseableResource<UnderFileSystem> ufsResource = mUfsManager.getRoot().acquireUfsResource()) { String backupParentDir = request.hasTargetDirectory() ? request.getTargetDirectory() : ServerConfiguration.get(PropertyKey.MASTER_BACKUP_DIRECTORY); UnderFileSystem ufs = ufsResource.get(); if (request.getOptions().getLocalFileSystem() && !ufs.getUnderFSType().equals("local")) { ufs = UnderFileSystem.Factory.create("/", UnderFileSystemConfiguration.defaults(ServerConfiguration.global())); } if (!ufs.isDirectory(backupParentDir)) { if (!ufs.mkdirs(backupParentDir, MkdirsOptions.defaults(ServerConfiguration.global()).setCreateParent(true))) { throw new IOException(String.format("Failed to create directory %s", backupParentDir)); } } Instant now = Instant.now(); String backupFileName = String.format(BackupManager.BACKUP_FILE_FORMAT, DateTimeFormatter.ISO_LOCAL_DATE.withZone(ZoneId.of("UTC")).format(now), now.toEpochMilli()); String backupFilePath = PathUtils.concatPath(backupParentDir, backupFileName); String rootUfs = ServerConfiguration.get(PropertyKey.MASTER_MOUNT_TABLE_ROOT_UFS); if (request.getOptions().getLocalFileSystem()) { rootUfs = "file:/ } backupUri = new AlluxioURI(new AlluxioURI(rootUfs), new AlluxioURI(backupFilePath)); try { try (OutputStream ufsStream = ufs.create(backupFilePath)) { mBackupManager.backup(ufsStream, entryCounter); } } catch (IOException e) { try { ufs.deleteExistingFile(backupFilePath); } catch (Exception e2) { LOG.error("Failed to clean up failed backup at {}", backupFilePath, e2); e.addSuppressed(e2); } throw e; } } return backupUri; }

Target:
protected AlluxioURI takeBackup(BackupPRequest request, AtomicLong entryCounter) throws IOException { AlluxioURI backupUri; try (CloseableResource<UnderFileSystem> ufsResource = mUfsManager.getRoot().acquireUfsResource()) { String backupParentDir = request.hasTargetDirectory() ? request.getTargetDirectory() : ServerConfiguration.get(PropertyKey.MASTER_BACKUP_DIRECTORY); UnderFileSystem ufs = ufsResource.get(); if (request.getOptions().getLocalFileSystem() && !ufs.getUnderFSType().equals("local")) { ufs = UnderFileSystem.Factory.create("/", UnderFileSystemConfiguration.defaults(ServerConfiguration.global())); } if (!ufs.isDirectory(backupParentDir)) { if (!ufs.mkdirs(backupParentDir, MkdirsOptions.defaults(ServerConfiguration.global()).setCreateParent(true))) { throw new IOException(String.format("Failed to create directory %s", backupParentDir)); } } Instant now = Instant.now(); String backupFileName = String.format(BackupManager.BACKUP_FILE_FORMAT, DateTimeFormatter.ISO_LOCAL_DATE.withZone(ZoneId.of("UTC")).format(now), now.toEpochMilli()); String backupFilePath = PathUtils.concatPath(backupParentDir, backupFileName); String rootUfs = ServerConfiguration.get(PropertyKey.MASTER_MOUNT_TABLE_ROOT_UFS); if (request.getOptions().getLocalFileSystem()) { rootUfs = "file:/ } backupUri = new AlluxioURI(new AlluxioURI(rootUfs), new AlluxioURI(backupFilePath)); try { try (OutputStream ufsStream = ufs.create(backupFilePath)) { mBackupManager.backup(ufsStream, entryCounter); } } catch (IOException e) { try { ufs.deleteExistingFile(backupFilePath); } catch (Exception e2) { LOG.error("Failed to clean up failed backup at {}", backupFilePath, e2); e.addSuppressed(e2); } throw new IOException(String.format("Backup failed. BackupUri: %s, LastEntryCount: %d", backupUri, entryCounter.get()), e); } } return backupUri; }