Rename packages in order to make future stable documentation clearer.
[lgpl/argeo-commons.git] / org.argeo.maintenance / src / org / argeo / maintenance / backup / LogicalBackup.java
index d1b31b3ecabb16b435524cc7313f6325ce0ff4b2..a292dcf23fb5d7d7e69d18cdcd0561608a9f14bd 100644 (file)
@@ -31,13 +31,19 @@ import javax.jcr.Session;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.argeo.api.NodeUtils;
 import org.argeo.jcr.JcrUtils;
-import org.argeo.node.NodeUtils;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.xml.sax.SAXException;
 
-public class LogicalBackup {
+/**
+ * Performs a backup of the data based only on programmatic interfaces. Useful
+ * for migration or live backup. Physical backups of the underlying file
+ * systems, databases, LDAP servers, etc. should be performed for disaster
+ * recovery.
+ */
+public class LogicalBackup implements Runnable {
        private final static Log log = LogFactory.getLog(LogicalBackup.class);
 
        public final static String WORKSPACES_BASE = "workspaces/";
@@ -48,13 +54,6 @@ public class LogicalBackup {
        private final ZipOutputStream zout;
        private final Path basePath;
 
-       public LogicalBackup(BundleContext bundleContext, Repository repository, ZipOutputStream zout) {
-               this.repository = repository;
-               this.zout = zout;
-               this.basePath = null;
-               this.bundleContext = bundleContext;
-       }
-
        public LogicalBackup(BundleContext bundleContext, Repository repository, Path basePath) {
                this.repository = repository;
                this.zout = null;
@@ -62,6 +61,25 @@ public class LogicalBackup {
                this.bundleContext = bundleContext;
        }
 
+//     public LogicalBackup(BundleContext bundleContext, Repository repository, ZipOutputStream zout) {
+//     this.repository = repository;
+//     this.zout = zout;
+//     this.basePath = null;
+//     this.bundleContext = bundleContext;
+//}
+
+       @Override
+       public void run() {
+               try {
+                       log.info("Start logical backup to " + basePath);
+                       perform();
+               } catch (Exception e) {
+                       e.printStackTrace();
+                       throw new IllegalStateException("Logical backup failed", e);
+               }
+
+       }
+
        public void perform() throws RepositoryException, IOException {
                for (Bundle bundle : bundleContext.getBundles()) {
                        String relativePath = OSGI_BASE + "boot/" + bundle.getSymbolicName() + ".jar";