Magnolia 4.5 reached end of life on June 30, 2016. This branch is no longer supported, see End-of-life policy.
Importing and exporting content and data is useful when migrating content from one system to another, taking a backup or bringing in a custom taxonomy. The default file format for content exports is JCR System View XML. You can also export content hierarchies to a ZIP archive. The tools available range from a quick right-click export to scripting and writing custom import handlers depending on the frequency of use.
The file formats that can be used for imports and exports include:
website.demo-project.about.xml. When used to export a node, the node's subnodes are also included.
You can initiate imports and exports in AdminCentral with the context menu (right-click). This option is not available in all repositories.
If a node is selected when performing an import, then the imported node or data becomes children of the specified parent. If no node or data is specified, then the top imported node or data is included at the root of the repository or path into which the import is initiated.
To export XML:
If you right-click the white space on the page, the export includes all nodes. If you right-click on a node or data, the export includes that node or data and their children.
To import XML:
If a content node in the incoming has a unique ID (UUID) that is already used in the repository, the imported UUID will be changed.
You can upload a ZIP file in the Documents workspace. See the Export tool on how to export content to a ZIP file.
To import a ZIP file:
Use the import tool to import XML files to all repositories including those not available with the context menu.
This tool uses the to import and export page content in CSV and Excel formats. The module's documentation contains procedures for exporting and importing content into Magnolia as well as performing the translation.
When exported as a Google Spreadsheet, the translation will occur automatically when exported spreadsheet is opened in Google Docs.
You can export content from Magnolia using a simple Groovy script. This example exports the
news-overview page and children provided in
demo-project. This script performs the functionality equivalent to exporting to XML for the
Similarly, you can import content with the following Groovy script. It imports the content exported for
news-overview and imports it into
demo-project. This script performs the functionality equivalent to right-clicking
/demo-project/news-and-events and importing the XML file.
For more information on Groovy see
API provides information on the parameters for the
Import and export functionality is implemented in package
info.magnolia.importexport. This implementation is primarily contained within the
PropertiesImportExport classes. You can invoke methods in these classes from a custom class. An example for implementing the
These classes will not complete the import for any UUIDs that are identical to existing UUIDs.
and modules include examples of commands that import and export content. The commands use an import handler that corresponds to the data type upon which the command is invoked. For example,
CompanyImportHandler is used to import company data while
RSSFeedImportHandler is used to import RSS aggregator data.
Both handlers extend the
ImportHandler class in the Data module.
ImportHandler provides the common functionality needed for all import handlers such as tracking configuration characteristics (repository, name, target). You can write your own import handler by extending the
ImportHandler class. In your custom handler, read the incoming data and assign it to parameters as configured in the data type. Implement the
doImport method to do the actual data processing such as parsing the incoming file.
See in Content Translation Support module is another example. These examples also show how an import handler can be periodically executed without a corresponding command. Using the Data module to import data gives an example of an import handler that is executed at the same time every night. This example includes a import handler implementation that parses and processes a non-XML file. This import handler implementation extends
SimpleImportHandler which in turn is an extension of
onDoImport method needs to implemented when extending
There are various operations in which importing and exporting can be helpful.
You can also use the packager module for DMS assets transfer. The
dms repository can be selected for populating a package. Assets can then be selected for inclusion in the package. The package containing the assets can be downloaded and uploaded to another Magnolia system for installation.
You can accomplish site migration in a number of ways.
You can back up content by exporting it to XML or ZIP and storing the files in a disaster recovery system. The name of the file containing the XML reflects the path of the exported data making identification easier.
You can also use the Packager module for backups. The name of the downloaded package can be set to indicate the date of the backup or some other type of identification. The packages can be stored in a DR system.
The Backup module is an alternative to file system and database backup solutions. The module features immediate interactive backup of JackRabbit backed repositories and scheduled recurring backup support with cron like configuration options.
The recommended procedure for importing tags depends on the size and format of the taxonomy as well as whether the taxonomy needs to be added once or repeatedly. Depending on your need, you can import the tags into the existing
Category data type or add a new data type.
If the taxonomy does not need to be added repeatedly you should enter the taxonomy manually in AdminCentral if the size and format is such that it can reasonably be manually entered.
To enter a taxonomy manually into the existing
Category data type:
Moviesbranch with a genre scheme as children.
If you prefer to create a new data type:
If the taxonomy is too large to enter manually but needs to be entered only once then you should write a Groovy script to process a file containing the taxonomy.
Use a Groovy script to import a large taxonomy once:
websiteand root the path of the parent data type such as
Write an import handler to import a taxonomy repeatedly:
/modules/data/config/importerswith properties set to execute as needed.
You can use the tags in an imported taxonomy to classify content once the import is completed. Keep in mind that the data type will not have functionality such as that are available with the example
Category data type. You can add such functionality by copy and customizing.
The new taxonomy can be used as options for some control types. For instance, you can use subtypes as options for
select controls by setting the
labelNodeData properties. For the movies example,
repository would be set to
/movies. Assuming that a
name property is set for each movie category, you would set