22 Exporting and Importing Partitions

This chapter describes how to export and import partitions in Oracle WebLogic Server Multitenant (MT). You can use either Oracle Enterprise Manager Fusion Middleware Control (FMWC), the Oracle WebLogic Server Administration Console, or WebLogic Scripting Tool (WLST) to export and import partitions, as described in this chapter. The chapter refers to the Oracle Fusion Middleware and WebLogic Server documentation sets and online for additional information as appropriate.

This chapter includes the following sections:

Exporting and Importing Domain Partitions: Overview

Using WLST (online or offline), a Representational State Transfer (REST) API (online only), or the WebLogic Server Administration Console (online only), system administrators can export a domain partition and then import a previously exported partition into a different domain.

Exporting and importing partitions lets you easily move partitions from one domain to another, including the applications that are deployed to the partition. This feature is useful for replicating partitions across domains and for moving domains from a development to a production environment.

About Exporting Partitions

When a partition is exported from the source domain, it is packaged in a partition archive file that includes:

  • The partition configuration

  • Any resource groups contained in the partition

  • Any resource group templates referred to by those resource groups

  • The contents of the partition's file system, <partition-file-system>/config directory

  • Optionally, application binary files and configurations for applications deployed to the partition

No application runtime state, nor application-specific runtime configuration is included in the partition archive file. Other examples of what would not be exported are JMS messages in queues and users in an embedded LDAP realm.

Creating the Partition Archive File

You can use the WLST exportPartition command to create a partition archive file, <PartitionName>.zip. It copies a partition's configuration into the archive file as well as (optionally) the partition's applications and libraries. This command also creates the attributes.json file that you can use to modify the partition's configuration on import.

The command syntax is:

exportPartition(partitionName, expArchPath, [includeAppsNLibs], [keyFile])

partitionName is the name of the partition to export, expArchPath is the full path to the directory in which to save the partition archive file, includeAppsNLibs (optionally), specifies whether to include application and library binary files in the partition archive file, and keyFile (optionally), provides the full path to a file containing a string to use as the encryption key to encrypt attributes in the partition archive file. See Exporting Domain Partitions: WLST Example.

Partition Archive File Contents

A partition archive is a .zip file containing these specific partition-related files:


Files and Directories Description

partition-config.xml

Contains the partition configuration and resource group templates configuration from config.xml.

MANIFEST.MF

Includes a time stamp and domain information for the archive file.

<PartitionName>-attributes.json

Contains the MBean attributes and properties which can be changed by the administrator while importing the partition. In addition to being contained in the archive file, a copy of this file is also located with the archive file in the file system to make it easier to update.

expPartSecret

Contains the encrypted secret key used for encrypting and decrypting encrypted attributes.

domain/config/resource-group-templates/<resource_template_name>/*

Contains files related to any resource group template associated with this partition.

domain/config/partitions/<partition-name>/*

Specifies the configuration files under domain/config/partitions/<partition-name>/config/*.

pfs/config/*

Contains the <partition-file-system>/config directory content. This would also include system resources (JMS, JDBC, and such) descriptor files.

domain/upload/resource-group-templates/<resource_template_name>/<application_name>/

Contains resource group template-level binary files.

pfs/upload/<application_name>/

Contains resource group-level application binary files.


About Importing Partitions

A prerequisite to importing a partition is that the server instance must already have a domain configured. When a partition is imported into a new domain, some external systems may need to be configured to be aware of the newly imported partition. While importing a partition archive file, the system administrator may need to update the dependencies on the domain (like virtual targets, security realms, and resource group templates) and also optionally update other attributes in the partition configuration to make it valid, such as partition properties, JDBC, JMS, and other resources in resource groups. In addition, applications and system resources need to be deployed for the new partition.

During the import operation, the system administrator can override specific portions of the partition configuration by supplying a <PartitionName>-attributes.json file with modified attributes suitable for the target domain. However, changing the value of the name attribute is not supported; for example, "name" : "P1" in the following sample <PartitionName>-attributes.json cannot be changed.

{
    "partition" : {
         "name" : "P1",
         "jdbc-system-resource-override" : {
                "URL" : "url.com",
                "Id" : "0",
                "name" : "test123",
                "CachingDisabled" : "false",
                "Registered" : "false",
                "User" : "test123",
                "DynamicallyCreated" : "false",
                "DataSourceName" : "test-source"
         },
    "resource-group-template" : {
         "name" : "RGT1",
         "jdbc-system-resource" : {
            "name" : "jdbc1",
            "descriptor-file-name" : "jdbc/P1DB1-8882-jdbc.xml"
        }
 
         "jms-server-resource" : {
            "name" : "jms1",
            "PagingDirectory" : ""
        }
 
  
 }
}

In the prior example, all the JDBCSystemResourceOverrideMBean attributes are copied to the <PartitionName>-attributes.json file along with their current values.

If a resource group template already exists in the target domain, then you must use the createNew option to overwrite the existing resource group template and create a new one using a new name. (See Step 2 in Importing Domain Partitions: Main Steps.)

Exporting and Importing Applications

When a partition is exported, whether or not application binary files are included in the partition archive file is determined by the value of the includeApps option on the export operation. If includeApps is true, then the binary files are included. If false, then they are excluded. The <PartitionName>-attributes.json file contains attributes for the application or library source path, deployment plan path, and staging mode. You can change these attributes in the <PartitionName>-attributes.json file.

The includeApps option also affects how the application is deployed upon being imported:

  • If true (default), then the deployment files are copied to <domain-dir>/<server>/upload or <partition-dir>/<server>/upload, depending on whether it is a resource group template-level application or resource group-level application, and deployed using the original staging mode. If the staging mode is NOSTAGE or EXTERNAL (on the targeted server), then the system administrator is responsible for making the application available from the correct location in the target domain.

  • If false, then the system administrator is responsible for making the application available from the correct location in the target domain.

Exporting and Importing Encrypted Attributes

During the export operation, a new secret key is generated and stored in the expPartSecret file in the exported <PartitionName>.zip file. All the encrypted attributes in the partition-config.xml file and any system resource descriptors that are part of <PartitionName>.zip will be encrypted using the new secret key in the expPartSecret file. Alternatively, you can provide your own secret key by using the keyFile option.

During the import operation, after the entire partition is read and the attributes changed in accordance with the <PartitionName>-attributes.json file, the following steps are used to process encrypted attributes:

  1. The secret key in the expPartSecret file in the exported .zip is read.

  2. The secret key is decrypted using a second key that is either the default key in the WebLogic Server source, or the key provided using the keyFile option to import. The user-provided key must match the key used on import.

  3. All the encrypted attributes in the partition MBean (read and modified in the export operation) are decrypted using the key read from the expPartSecret file.

  4. All the encrypted attributes in the partition MBean are encrypted with the domain-specific key (SerializedSystemIni.dat) for the imported domain.

Exporting and Importing Domain Partitions: Main Steps and WLST Examples

You can export a domain partition (the source domain) with its entire configuration and data, as a partition archive file. With few configuration changes, you can then import the partition archive file into another instance of WebLogic Server MT (the target domain). You might need to update domain dependencies, such as virtual targets and security realms, and optionally update other attributes in the partition configuration to make it valid.

Exporting Domain Partitions: Main Steps

Prior to exporting a domain partition, you must first have created or imported one.

The main steps for exporting domain partitions are as follows:

  1. Select the domain partition that you want to export.
  2. Provide the full path to the directory in which to save the partition archive file.

    Each domain partition should be located in its own directory. The domain partition archive file is overwritten if it already exists in the specified location. Other files in the directory may be overwritten as well.

  3. Optionally, select to include the installed application and library binary files in the exported partition archive file.
  4. Optionally, enter the full path to a file containing a string to use as the encryption key to encrypt attributes in the partition archive file.

    If you do not provide your own key, then a new secret key will be generated and stored in the expPartSecret file in the exported <PartitionName>.zip file.

Exporting Domain Partitions: WLST Example

The following WLST command exports partition-1 to the /var/tmp directory. Application and library binary files are not included. /home/foo/mykeyfile is the path to the mykeyfile encryption key.

wls:/mydomain/serverConfig> exportPartition("partition-1", "/var/tmp/", false, "/home/foo/mykeyfile")

Importing Domain Partitions: Main Steps

Prior to importing a domain partition:

  • You must have previously exported a domain partition (the source domain) to a partition archive file.

  • The server instance must already have a domain configured (the target domain).

The main steps for importing domain partitions are as follows:

  1. Provide the full path to the partition archive file that you want to import.
  2. Optionally, select the overwrite existing resource group templates option if the resource group template already exists in the target domain and you want to create a new one using a new name.

    All resource group templates used by the source domain partition are contained in the partition archive file and are imported along with the partition into the target domain. If the resource group template already exists in the target domain and you do not specify to overwrite the existing resource group template, then the import operation will fail.

  3. Optionally, specify a name to use for the partition when it is created in the target domain. This defaults to the original name of the partition.
  4. Optionally, enter the full path to a file containing the key to decrypt attributes in the partition archive file.

Importing Domain Partitions: WLST Example

The following WLST command imports the partition-1 archive file located in the /var/tmp directory. Application and library binary files are not included. The file /home/foo/mykeyfile is used as the encryption key.

wls:/mydomain/serverConfig> importPartition("/var/tmp/partition-1.zip", keyFile="/home/foo/mykeyfile")

Exporting and Importing Domain Partitions: Related Tasks and Links

See the following for additional information: