Import and exporting branches and sites
This topic describes import and export formats and types, shows to export page branches and sites, and shows how to call the import service. The topics also includes use cases on backing up a site or server, migrating content, and importing external content.
Jahia supports different formats for importing content, based on XML.
XML Import files can be packaged inside a zip file if multiple import files need to be imported, if binary files are present in the import, or if multiple workspace (default and live) needs to be imported.
When exporting a node, multiple options are available :
Import also supports legacy formats, for migration of older versions of Jahia.
JCR document view
The principal format that is used is based on the standard document view from the JCR specifications. In this simple format, each node is an XML tag, and each property is an XML attribute. This format directly reflects the structure that is used to store content inside the JCR.
A simple news from the ACME demo site will be exported like that :
<news_36 image="/sites/ACME22/files/images/generic-pictures/illustration8.jpg" j:defaultCategory="/sites/systemsite/categories/project"
j:lastPublished="2011-10-17T11:15:42.161+02:00" j:lastPublishedBy="root" j:originWS="default" j:published="true"
jcr:created="2011-02-01T16:40:07.725+01:00" jcr:createdBy="root" jcr:lastModified="2011-10-17T13:24:53.353+02:00"
jcr:lastModifiedBy="root" jcr:mixinTypes="jmix:accessControlled jmix:categorized" jcr:primaryType="jnt:news">
<j:translation_en desc="<p> From the concept to completion, it took 6 yecdscdsars for this building of 180-metres high ..."
j:lastPublished="2011-10-17T11:15:42.161+02:00" j:lastPublishedBy="root" j:published="true" jcr:language="en"
jcr:lastModified="2011-10-17T13:24:53.321+02:00" jcr:lastModifiedBy="root" jcr:lockIsDeep="false" jcr:lockOwner="root"
jcr:mixinTypes="mix:title" jcr:primaryType="jnt:translation" jcr:title="New 5 stars hotel in Hong Kong build by ACME Contruction"/>
<j:translation_fr desc="<p> De la conception à la réalisation, il a fallu 6 ans pour ce bâtiment de d..."
jcr:language="fr" jcr:lastModified="2011-02-01T16:40:14.671+01:00" jcr:lastModifiedBy="root" jcr:mixinTypes="mix:title"
jcr:primaryType="jnt:translation" jcr:title="Nouvel hôtel 5 étoiles à Hong Kong, construit par ACME International"/>
Export ZIP: Export with binaries
This option will include the binaries along with the XML export file.
The XML document view is called repository.xml. All binaries associated to nodes in repository.xml will be stored in a content sub-directory.
The path of the binary file is based on the path of the nt:resource node in the tree. As multiple binary resources can be associated to a single file node (for example for thumbnails), a folder with the name of the file node is created. For each nt:resource node, a file is created. The file corresponding to the jcr:content node will have the same name as the file node.
For a file node which path is /sites/ACME/files/PDF/Publications/ACME_WP_BuildingBridges.pdf, the export will look like :
Export ZIP with live content
In the case of an export containing live content, the document view file will be called live-repository.xml, and associated binaries will be in live-content .
Content export files from Jahia prior to version 6.6 uses a different format, based on the page / container lists / container structure. This format is still supported for compatibility, and can eventually be used along with a mapping file for migration purpose.
Other legacy formats are supported for specific content import:
- The categories.xml file allows you to import categories in the system site
- The users.xml file imports users and groups
- The filesacl.xml file imports ACLs and metadata on files
This is the standard export, which can be obtained on any node, with the export action in the context menus. It will contains a document view of the node and all its sub nodes.
Branch exports can be imported with the import option in the context menu - a new node will be created with all the content of the export file.
A site export can be obtained through the administration. Compared to the branch export, it contains additional information, stored in a site.properties file. A full export with live and staging content is available. It is also possible to export the staging content only.
The export file is packaged into a ZIP containing an export.properties file, one zip for the users, and one zip for each exported site.
A site export can be imported in the administration only, with the Import archive option.
You can directly call the Export service, for instance from a shell script, to automatize site or content exports.
- Full site with live content : http://localhost:8080/cms/export/default/sites/ACME-SPACE.zip?live=true
- Home page in XML format : http://localhost:8080/cms/export/default/sites/ACME-SPACE/home.xml
Common use cases
Export can be used to backup a site or a full Jahia server. A full export with live content can be used for this purpose : the site will be restored in the same state as it was exported.
Note that content versions are not exported - only the current state of the web project is backed up.
As Jahia supports legacy import formats, it can be used to migrate content from a version prior to 6.6. The use of mapping files can help to map container and fields to a new content structure.
External content import
The format of the document view is easily understandable and can be generated by an external system.