}
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());
}
problems = session.getWorkspace().getRepositoryManager().restoreRepository(backupDirectory);