if (path == null || path.trim().length() == 0) {
throw new IllegalStateException("Cannot locate the jboss server dir");
}
final File backupDirectory = new File(path);
Repository repository = (Repository)getRepositoryFromJndi("java:/jcr/sample");
org.modeshape.jcr.api.Session session = repository.login();
final RepositoryManager repoMgr = session.getWorkspace().getRepositoryManager();
Problems problems = repoMgr.backupRepository(backupDirectory);
if (problems.hasProblems()) {
throw new IllegalStateException("Errors while backing up repository:" + problems.toString());
}