@POST
    public Response runBackup(final InputStream bodyStream) throws IOException {

        File backupDirectory;
        if (null != bodyStream) {
            final String body = IOUtils.toString(bodyStream).trim();

            backupDirectory = new File(body.trim());
            if (body.isEmpty()) {
                // Backup to a temp directory
                backupDirectory = createTempDir();

            } else if (!backupDirectory.exists() || !backupDirectory.canWrite()) {
                throw new WebApplicationException(
                        serverError().entity(
                                "Backup directory does not exist or is not writable: " +
                                        backupDirectory.getAbsolutePath())
                                .build());
            }

        } else {
            // Backup to a temp directory
            backupDirectory = createTempDir();
        }

        LOGGER.debug("Backing up to: {}", backupDirectory.getAbsolutePath());
        final Collection<Throwable> problems = repositoryService.backupRepository(session.getFedoraSession(),
                backupDirectory);

        if (!problems.isEmpty()) {
            LOGGER.error("Problems backing up the repository:");

            // Report the problems (we'll just print them out) ...
            final String output = problems.stream().map(Throwable::getMessage).peek(LOGGER::error)
                    .collect(joining("\n"));

            throw new WebApplicationException(serverError().entity(output).build());

        }
        return ok()
            .header("Warning", "This endpoint will be moving to an extension module in a future release of Fedora")
            .entity(backupDirectory.getCanonicalPath()).build();
    }
@ POST public Response runBackup ( final InputStream bodyStream ) throws IOException { File backupDirectory ; if ( null != bodyStream ) { final String body = IOUtils . toString ( bodyStream ) . trim ( ) ; backupDirectory = new File ( body . trim ( ) ) ; if ( body . isEmpty ( ) ) { backupDirectory = createTempDir ( ) ; } else if ( ! backupDirectory . exists ( ) || ! backupDirectory . canWrite ( ) ) { throw new WebApplicationException ( serverError ( ) . entity ( "Backup directory does not exist or is not writable: " + backupDirectory . getAbsolutePath ( ) ) . build ( ) ) ; } } else { backupDirectory = createTempDir ( ) ; } LOGGER . debug ( "Backing up to: {}" , backupDirectory . getAbsolutePath ( ) ) ; final Collection < Throwable > problems = repositoryService . backupRepository ( session . getFedoraSession ( ) , backupDirectory ) ; if ( ! problems . isEmpty ( ) ) { LOGGER . error ( "Problems backing up the repository:" ) ; final String output = problems . stream ( ) . map ( Throwable :: getMessage ) . peek ( LOGGER :: error ) . collect ( joining ( "\n" ) ) ; throw new WebApplicationException ( serverError ( ) . entity ( output ) . build ( ) ) ; } return ok ( ) . header ( "Warning" , "This endpoint will be moving to an extension module in a future release of Fedora" ) . entity ( backupDirectory . getCanonicalPath ( ) ) . build ( ) ; }
This method runs a repository backup.

@param bodyStream the input body stream
@return path to the backup
@throws IOException if IO exception occurred