Red Hat Training

A Red Hat training course is available for Red Hat JBoss Data Virtualization

Chapter 1. Migrating your data

Use Red Hat JBoss Data Virtualization's backup and restore functionality to migrate the data stored in your hierarchical database. Each backup you create will contain all of the content for all of the workspaces in a single repository. Therefore, you will need to back up and restore each of your repositories one by one.
The backup and restore functionality is provided by the org.modeshape.jcr.api.RepositoryManager interface:
public interface RepositoryManager {

    ...

    Problems backupRepository( File backupDirectory ) throws RepositoryException;

    ...

    Problems restoreRepository( File backupDirectory ) throws RepositoryException;

    ...

}
Run this code in an Apache Jackrabbit (JCR) session in any workspace to access the repository manager:
javax.jcr.Repository repository = ...
javax.jcr.Credentials credentials = ...
String workspaceName = ...
javax.jcr.Session session = repository.login(credentials,workspaceName);
org.modeshape.jcr.api.Session msSession = (org.modeshape.jcr.api.Session)session;
org.modeshape.jcr.api.RepositoryManager repoMgr = ((org.modeshape.jcr.api.Session)session).getWorkspace().getRepositoryManager();

1.1. Back up your repository

Use the backupRepository method provided by the org.modeshape.jcr.api.RepositoryManager interface to back up your repository. All of the workspaces that existed when the back up was initiated will be saved. If you call the backup method on a repository that is in use, all of the changes made while the backup process is underway are also saved.

Note

The method blocks other calls until the backup is completed, so you must invoke the method asynchronously to avoid disruptions.
Each backup is stored on the file system in a series of Gzip archives. A sub-directory for storing large binaries is also created.
  • To back up your repository, run this code in your Apache JCR session:
    org.modeshape.jcr.api.RepositoryManager repoMgr = ...
    java.io.File backupDirectory = ...
    Problems problems = repoMgr.backupRepository(backupDirectory);
    if ( problems.hasProblems() ) {
        System.out.println("Problems restoring the repository:");
        // Report the problems (we'll just print them out) ...
        for ( Problem problem : problems ) {
           System.out.println(problem);
        }
    } else {
        System.out.println("The backup was successful");
    }

Note

You must initiate each operation. There is no way to automatically schedule a backup.