JBoss.orgCommunity Documentation

Chapter 37. HTTPBackupAgent and backup client

37.1. Introduction
37.2. HTTPBackupAgent
37.2.1. HTTPBackupAgent methods
37.2.2. HTTPBackupAgent Configuration
37.3. Backup Client
37.4. Backup Client Usage
37.4.1. Building application
37.4.2. Running application
37.4.3. Getting information about backup service
37.4.4. Starting full backup
37.4.5. Starting full and incremental backup on a single workspace
37.4.6. Getting information about the current backups (in progress)
37.4.7. Getting information about the current backup by 'backup_id'
37.4.8. Stopping backup by "backup_id"
37.4.9. Getting information about the completed (ready to restore) backups
37.4.10. Restoring to workspace
37.4.11. Getting information about the current restore
37.4.12. Restoring workspace and remove exists workspace
37.4.13. Restoring workspace from backup set
37.4.14. Restoring workspace from backup set and remove exists workspace
37.4.15. Restoring workspace with original configuation
37.4.16. Restoring workspace with original configuation and remove exists workspace
37.4.17. Restoring workspace from backup set with original configuation
37.4.18. Restoring workspace from backup set with original configuation and remove exists workspace
37.4.19. Restoring repository
37.4.20. Restoring repository and remove exists repository
37.4.21. Restoring repository from backup set
37.4.22. Restoring repository from backup set and remove exists repository
37.4.23. Restoring repository with original configuation
37.4.24. Restoring repository with original configuation and remove exists repository
37.4.25. Restoring repository from backup set with original configuation
37.4.26. Restoring repository from backup set with original configuation and remove exists repository
37.5. Full example about creating backup and restoring it for workspace 'backup'
37.5.1. Creating backup
37.5.2. Getting information about current backups
37.5.3. Stopping backup by id
37.5.4. Deleting the workspace "backup" and close opened sessions on this workspace
37.5.5. Restoring the workspace "backup"
37.5.6. Getting information about restore for workspace /repository/backup
37.6. Full example about creating backup and restoring it for repository 'repository'
37.6.1. Creating backup
37.6.2. Getting information about current backups
37.6.3. Stopping backup by id
37.6.4. Deleting the repository "repository" and close all opened sessions
37.6.5. Restoring the repository "repository"
37.6.6. Getting information about restore for repository 'repository'

Warning

For this service, you should configure the org.exoplatform.services.jcr.impl.config.JDBCConfigurationPersister in order to save the changes of the repository configuration. See the eXo JCR Configuration article at chapter '2 Portal and Standalone configuration' .

GateIn uses context /portal/rest, therefore you need to use http://host:port/portal/rest/ instread of http://host:port/rest/

GateIn uses form authentication, so first you need to login (url to form authentication is http://host:port/portal/login) and then perform requests.

The service org.exoplatform.services.jcr.ext.backup.server.HTTPBackupAgent is REST-based front-end to service org.exoplatform.services.jcr.ext.backup.BackupManager. HTTPBackupAgent is representation BackupManager to creation backup, restore, getting status of current or completed backup/restore, etc.

The backup client is http client for HTTPBackupAgent.

The HTTPBackupAgent is based on REST (see details about the REST Framework).

HTTPBackupAgent is using POST and GET methods for request.

The HTTPBackupAgent allows :

  • Start backup

  • Stop backup

  • Restore from backup

  • Delete the workspace

  • Get information about backup service (BackupManager)

  • Get information about current backup / restores / completed backups

/rest/jcr-backup/start/{repo}/{ws}

Start backup on specific workspace

URL: http://host:port/rest/jcr-backup/start/{repo}/{ws}

Formats: json.

Method: POST

Parameters:

The BackupConfigBean:

header :
"Content-Type" = "application/json; charset=UTF-8"

body:
<JSON to BackupConfigBean>

The JSON bean of org.exoplatform.services.jcr.ext.backup.server.bean.BackupConfigBean :

{"incrementalRepetitionNumber":<Integer>,"incrementalBackupJobConfig":<JSON to BackupJobConfig>,
"backupType":<Integer>,"fullBackupJobConfig":<JSON to BackupJobConfig>,
"incrementalJobPeriod":<Long>,"backupDir":"<String>"}

Where :

backupType                  - the type of backup:
                                  0 - full backup only;
                                  1 - full and incremental backup.
backupDir                   - the path to backup folder;
incrementalJobPeriod        - the incremental job period;
incrementalRepetitionNumber - the incremental repetition number;
fullBackupJobConfig         - the configuration to full backup, JSON to BackupJobConfig;
incrementalJobPeriod        - the configuration to incremental backup, JSON to BackupJobConfig.

The JSON bean of org.exoplatform.services.jcr.ext.backup.server.bean.response.BackupJobConfig :

{"parameters":[<JSON to Pair>, ..., <JSON to pair> ],"backupJob":"<String>"}

Where:

backupJob  - the FQN (fully qualified name) to BackupJob class;
parameters - the list of JSON of Pair.

The JSON bean of org.exoplatform.services.jcr.ext.backup.server.bean.response.Pair :

{"name":"<String>","value":"<String>"}

Where:

name  - the name of parameter;
value - the value of parameter.

Returns:

/rest/jcr-backup/info/backup

Information about the current and completed backups

URL: http://host:port/rest/jcr-backup/info/backup

Formats: json

Method: GET

Parameters: no

Returns:

/rest/jcr-backup/info/backup/{id} Detailed information about a current or completed backup with identifier '{id}'.

URL: http://host:port/rest/jcr-backup/info/backup/{id}

Formats: json

Method: GET

Parameters:

Returns:

/rest/jcr-backup/restore/{repo}/{id}

Restore the workspace from specific backup.

URL: http://host:port/rest/jcr-backup/restore/{repo}/{id}

Formats: json.

Method: POST

Parameters:

The RestoreBean:

header :
"Content-Type" = "application/json; charset=UTF-8"

body:
<JSON to WorkspaceEntry>

The example of JSON bean to org.exoplatform.services.jcr.config.WorkspaceEntry :

{ "accessManager" : null,
  "autoInitPermissions" : null,
  "autoInitializedRootNt" : null,
  "cache" : { "parameters" : [ { "name" : "max-size",
            "value" : "10k"
          },
          { "name" : "live-time",
            "value" : "1h"
          }
        ],
      "type" : "org.exoplatform.services.jcr.impl.dataflow.persistent.LinkedWorkspaceStorageCacheImpl"
    },
  "container" : { "parameters" : [ { "name" : "source-name",
            "value" : "jdbcjcr"
          },
          { "name" : "dialect",
            "value" : "hsqldb"
          },
          { "name" : "multi-db",
            "value" : "false"
          },
          { "name" : "update-storage",
            "value" : "false"
          },
          { "name" : "max-buffer-size",
            "value" : "200k"
          },
          { "name" : "swap-directory",
            "value" : "../temp/swap/production"
          }
        ],
      "type" : "org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer",
      "valueStorages" : [ { "filters" : [ { "ancestorPath" : null,
                  "minValueSize" : 0,
                  "propertyName" : null,
                  "propertyType" : "Binary"
                } ],
            "id" : "system",
            "parameters" : [ { "name" : "path",
                  "value" : "../temp/values/production"
                } ],
            "type" : "org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage"
          } ]
    },
  "initializer" : { "parameters" : [ { "name" : "root-nodetype",
            "value" : "nt:unstructured"
          } ],
      "type" : "org.exoplatform.services.jcr.impl.core.ScratchWorkspaceInitializer"
    },
  "lockManager" : { "persister" : { "parameters" : [ { "name" : "path",
                "value" : "../temp/lock/system"
              } ],
          "type" : "org.exoplatform.services.jcr.impl.core.lock.FileSystemLockPersister"
        },
      "timeout" : 15728640
    },
  "name" : "production",
  "queryHandler" : { "analyzer" : {  },
      "autoRepair" : true,
      "bufferSize" : 10,
      "cacheSize" : 1000,
      "documentOrder" : true,
      "errorLogSize" : 50,
      "excerptProviderClass" : "org.exoplatform.services.jcr.impl.core.query.lucene.DefaultHTMLExcerpt",
      "excludedNodeIdentifers" : null,
      "extractorBackLogSize" : 100,
      "extractorPoolSize" : 0,
      "extractorTimeout" : 100,
      "indexDir" : "../temp/jcrlucenedb/production",
      "indexingConfigurationClass" : "org.exoplatform.services.jcr.impl.core.query.lucene.IndexingConfigurationImpl",
      "indexingConfigurationPath" : null,
      "maxFieldLength" : 10000,
      "maxMergeDocs" : 2147483647,
      "mergeFactor" : 10,
      "minMergeDocs" : 100,
      "parameters" : [ { "name" : "index-dir",
            "value" : "../temp/jcrlucenedb/production"
          } ],
      "queryClass" : "org.exoplatform.services.jcr.impl.core.query.QueryImpl",
      "queryHandler" : null,
      "resultFetchSize" : 2147483647,
      "rootNodeIdentifer" : "00exo0jcr0root0uuid0000000000000",
      "spellCheckerClass" : null,
      "supportHighlighting" : false,
      "synonymProviderClass" : null,
      "synonymProviderConfigPath" : null,
      "type" : "org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex",
      "useCompoundFile" : false,
      "volatileIdleTime" : 3
    },
  "uniqueName" : "repository_production"
}

Returns:

/rest/jcr-backup/info/default-ws-config Will be returned the JSON bean to WorkspaceEntry for default workspace.

URL: http://host:port/rest/jcr-backup/info/default-ws-config

Formats: json

Method: GET

Parameters: no

Returns:

Add the components org.exoplatform.services.jcr.ext.backup.server.HTTPBackupAgent and org.exoplatform.services.jcr.ext.backup.BackupManager to services configuration :

<component>
  <type>org.exoplatform.services.jcr.ext.backup.server.HTTPBackupAgent</type>
</component>

<component>
  <type>org.exoplatform.services.jcr.ext.repository.RestRepositoryService</type>
</component>

<component>
  <key>org.exoplatform.services.jcr.ext.backup.BackupManager</key>
  <type>org.exoplatform.services.jcr.ext.backup.impl.BackupManagerImpl</type>
  <init-params>
    <properties-param>
      <name>backup-properties</name>
      <property name="backup-dir" value="../temp/backup" />
    </properties-param>
  </init-params>
</component>

In case, if you will restore backup in same workspace (so you will drop previous workspace), you need configure RepositoryServiceConfiguration in order to save the changes of the repository configuration. For example

<component>
  <key>org.exoplatform.services.jcr.config.RepositoryServiceConfiguration</key>
  <type>org.exoplatform.services.jcr.impl.config.RepositoryServiceConfigurationImpl</type>
  <init-params>
    <value-param>
      <name>conf-path</name>
      <description>JCR repositories configuration file</description>
      <value>jar:/conf/portal/exo-jcr-config.xml</value>
    </value-param>
    <properties-param>
      <name>working-conf</name>
      <description>working-conf</description>
      <property name="source-name" value="jdbcjcr" />
      <property name="dialect" value="hsqldb" />
      <property name="persister-class-name" value="org.exoplatform.services.jcr.impl.config.JDBCConfigurationPersister" />
    </properties-param>
  </init-params>
</component>

See the eXo JCR Configuration article at chapter '2 Portal and Standalone configuration' for details.

Backup client is console application.

The backup client is http client for HTTPBackupAgent.

Command signature:

Help info:
 <url_basic_authentication>|<url form authentication>  <cmd> 
 <url_basic_authentication>  :   http(s)//login:password@host:port/<context> 

 <url form authentication>   :   http(s)//host:port/<context> "<form auth parm>" 
     <form auth parm>        :   form <method> <form path>
     <method>                :   POST or GET
     <form path>             :   /path/path?<paramName1>=<paramValue1>&<paramName2>=<paramValue2>...
     Example to <url form authentication> : http://127.0.0.1:8080/portal/rest form POST "/portal/login?initialURI=/portal/private&username=root&password=gtn"

 <cmd>  :   start <repo[/ws]> <backup_dir> [<incr>] 
            stop <backup_id> 
            status <backup_id> 
            restores <repo[/ws]> 
            restore [remove-exists] {{<backup_id>|<backup_set_path>} | {<repo[/ws]> {<backup_id>|<backup_set_path>} [<pathToConfigFile>]}} 
            list [completed] 
            info 
            drop [force-close-session] <repo[/ws]>  
            help  

 start          - start backup of repository or workspace 
 stop           - stop backup 
 status         - information about the current or completed backup by 'backup_id' 
 restores       - information about the last restore on specific repository or workspace 
 restore        - restore the repository or workspace from specific backup 
 list           - information about the current backups (in progress) 
 list completed - information about the completed (ready to restore) backups 
 info           - information about the service backup 
 drop           - delete the repository or workspace 
 help           - print help information about backup console 

 <repo[/ws]>         - /<reponsitory-name>[/<workspace-name>]  the repository or workspace 
 <backup_dir>        - path to folder for backup on remote server 
 <backup_id>         - the identifier for backup 
 <backup_set_dir>    - path to folder with backup set on remote server
 <incr>              - incemental job period 
 <pathToConfigFile>  - path (local) to  repository or workspace configuration 
 remove-exists       - remove fully (db, value storage, index) exists repository/workspace 
 force-close-session - close opened sessions on repository or workspace. 

 All valid combination of parameters for command restore: 
  1. restore remove-exists <repo/ws> <backup_id>       <pathToConfigFile> 
  2. restore remove-exists <repo>    <backup_id>       <pathToConfigFile> 
  3. restore remove-exists <repo/ws> <backup_set_path> <pathToConfigFile> 
  4. restore remove-exists <repo>    <backup_set_path> <pathToConfigFile> 
  5. restore remove-exists <backup_id> 
  6. restore remove-exists <backup_set_path> 
  7. restore <repo/ws> <backup_id>       <pathToConfigFile> 
  8. restore <repo>    <backup_id>       <pathToConfigFile> 
  9. restore <repo/ws> <backup_set_path> <pathToConfigFile> 
 10. restore <repo>    <backup_set_path> <pathToConfigFile> 
 11. restore <backup_id> 
 12. restore <backup_set_path> 
<repository-service default-repository="repository">
  <repositories>
    <repository name="repository" system-workspace="production" default-workspace="production">
      <security-domain>exo-domain</security-domain>
      <access-control>optional</access-control>
      <authentication-policy>org.exoplatform.services.jcr.impl.core.access.JAASAuthenticator</authentication-policy>
      <workspaces>
        
        <workspace name="backup">
          <container class="org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer">
            <properties>
              <property name="source-name" value="jdbcjcr" />
              <property name="dialect" value="pgsql" />
              <property name="multi-db" value="false" />
              <property name="update-storage" value="false" />
              <property name="max-buffer-size" value="200k" />
              <property name="swap-directory" value="../temp/swap/backup" />
            </properties>
            <value-storages>
              <value-storage id="draft" class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
                <properties>
                  <property name="path" value="../temp/values/backup" />
                </properties>
                <filters>
                  <filter property-type="Binary"/>
                </filters>
              </value-storage>
            </value-storages>
          </container>
          <initializer class="org.exoplatform.services.jcr.impl.core.ScratchWorkspaceInitializer">
            <properties>
              <property name="root-nodetype" value="nt:unstructured" />
            </properties>
          </initializer>
          <cache enabled="true" class="org.exoplatform.services.jcr.impl.dataflow.persistent.LinkedWorkspaceStorageCacheImpl">
            <properties>
              <property name="max-size" value="10k" />
              <property name="live-time" value="1h" />
            </properties>
          </cache>
          <query-handler class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
            <properties>
              <property name="index-dir" value="../temp/jcrlucenedb/backup" />
            </properties>
          </query-handler>
        </workspace>
      </workspaces>
    </repository>
  </repositories>
</repository-service>

This usecase needs RestRepositoryService enabled. (Deleting the repository needs it)

<component>
   <type>org.exoplatform.services.jcr.ext.repository.RestRepositoryService</type>
</component>
<repository-service default-repository="repository">
   <repositories>
      <repository name="repository" system-workspace="production" default-workspace="production">
         <security-domain>exo-domain</security-domain>
         <access-control>optional</access-control>
         <authentication-policy>org.exoplatform.services.jcr.impl.core.access.JAASAuthenticator</authentication-policy>
         <workspaces>
            <workspace name="production">
               <!-- for system storage -->
               <container class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
                  <properties>
                     <property name="source-name" value="jdbcjcr" />
                     <property name="multi-db" value="false" />
                     <property name="update-storage" value="false" />
                     <property name="max-buffer-size" value="200k" />
                     <property name="swap-directory" value="../temp/swap/production" />
                  </properties>
                  <value-storages>
                     <value-storage id="system" class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
                        <properties>
                           <property name="path" value="../temp/values/production" />
                        </properties>
                        <filters>
                           <filter property-type="Binary" />
                        </filters>
                     </value-storage>
                  </value-storages>
               </container>
               <initializer class="org.exoplatform.services.jcr.impl.core.ScratchWorkspaceInitializer">
                  <properties>
                     <property name="root-nodetype" value="nt:unstructured" />
                  </properties>
               </initializer>
               <cache enabled="true" class="org.exoplatform.services.jcr.impl.dataflow.persistent.LinkedWorkspaceStorageCacheImpl">
                  <properties>
                     <property name="max-size" value="10k" />
                     <property name="live-time" value="1h" />
                  </properties>
               </cache>
               <query-handler class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
                  <properties>
                     <property name="index-dir" value="../temp/jcrlucenedb/production" />
                  </properties>
               </query-handler>
               <lock-manager>
                  <time-out>15m</time-out>
                  <persister class="org.exoplatform.services.jcr.impl.core.lock.FileSystemLockPersister">
                     <properties>
                        <property name="path" value="../temp/lock/system" />
                     </properties>
                  </persister>
               </lock-manager>
            </workspace>

            <workspace name="backup">
               <container class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
                  <properties>
                     <property name="source-name" value="jdbcjcr" />
                     <property name="multi-db" value="false" />
                     <property name="update-storage" value="false" />
                     <property name="max-buffer-size" value="200k" />
                     <property name="swap-directory" value="../temp/swap/backup" />
                  </properties>
                  <value-storages>
                     <value-storage id="draft" class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
                        <properties>
                           <property name="path" value="../temp/values/backup" />
                        </properties>
                        <filters>
                           <filter property-type="Binary" />
                        </filters>
                     </value-storage>
                  </value-storages>
               </container>
               <initializer class="org.exoplatform.services.jcr.impl.core.ScratchWorkspaceInitializer">
                  <properties>
                     <property name="root-nodetype" value="nt:unstructured" />
                  </properties>
               </initializer>
               <cache enabled="true" class="org.exoplatform.services.jcr.impl.dataflow.persistent.LinkedWorkspaceStorageCacheImpl">
                  <properties>
                     <property name="max-size" value="10k" />
                     <property name="live-time" value="1h" />
                  </properties>
               </cache>
               <query-handler class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
                  <properties>
                     <property name="index-dir" value="../temp/jcrlucenedb/backup" />
                  </properties>
               </query-handler>
            </workspace>

            <workspace name="digital-assets">
               <container class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
                  <properties>
                     <property name="source-name" value="jdbcjcr" />
                     <property name="multi-db" value="false" />
                     <property name="update-storage" value="false" />
                     <property name="max-buffer-size" value="200k" />
                     <property name="swap-directory" value="../temp/swap/digital-assets" />
                  </properties>
                  <value-storages>
                     <value-storage id="digital-assets" class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
                        <properties>
                           <property name="path" value="../temp/values/digital-assets" />
                        </properties>
                        <filters>
                           <filter property-type="Binary" />
                        </filters>
                     </value-storage>
                  </value-storages>
               </container>
               <initializer class="org.exoplatform.services.jcr.impl.core.ScratchWorkspaceInitializer">
                  <properties>
                     <property name="root-nodetype" value="nt:folder" />
                  </properties>
               </initializer>
               <cache enabled="true" class="org.exoplatform.services.jcr.impl.dataflow.persistent.LinkedWorkspaceStorageCacheImpl">
                  <properties>
                     <property name="max-size" value="5k" />
                     <property name="live-time" value="15m" />
                  </properties>
               </cache>
               <query-handler class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
                  <properties>
                     <property name="index-dir" value="../temp/jcrlucenedb/digital-assets" />
                  </properties>
               </query-handler>
            </workspace>
         </workspaces>
      </repository>
   </repositories>
</repository-service>