Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This article explains how to copy a space from one instance to other instance using the Confluence Command Line Interface (CLI) app.

Note
titleImportant Information

Ensure that the

instance you want to copy from (source)

source instance must have the CLI Connector installed with a valid license.

Having

 A connector or a

connector/

valid license is not

required in

a requirement for the target instance.

 

Instructions

Use the copySpace action to copy space with space, targetServer, targetUser, targetPassword and name  name as required parameters    

...

.

As an example, let's copy the current space,

...

 CopySpace_CLI, with

...

key, COPYCLI, to another

...

Confluence instance with space name, TARGET_CLI. The copied space in the target instance retains the same space key, COPYCLI. 

Execute the following action:

Code Block
themeMidnight
--action copySpace --space "COPYCLI" --targetServer "http://confluence.destinationinstance.com" --targetUser "admin" --targetPassword "admin" --name "TARGET_CLI"  --description "copied space" --copyComments --copyLabels  --descendents

...

Image Added

The result of the above action is as follows:

  • Output on the terminal:

    Code Block
    themeMidnight
     --action copySpace --space "COPYCLI" --targetServer "http://confluence.destinationinstance.com" --targetUser "admin" --targetPassword "admin" --name "TARGET_CLI"  --description "copied space" --copyComments --copyLabels  --descendents
    
    Space added with key COPYCLI, name 'TARGET_CLI', and url http://confluence.destinationinstance.com/display/COPYCLI.
    Page 'Confluence_CLI Home' copied to 'Confluence_CLI Home' in COPYCLI.
    Page 'addPage_CLI' copied to 'addPage_CLI' in COPYCLI with parent 'Confluence_CLI Home'.
    2 comments copied from page 'addPage_CLI' to 'addPage_CLI' in space COPYCLI on target server http://confluence.destinationinstance.com.
    1 labels copied.
    Page 'CLI_Title_3' copied to 'CLI_Title_3' in COPYCLI with parent 'addPage_CLI'.
    Page 'Blogging tutorial' copied to 'Blogging tutorial' in COPYCLI with parent 'Confluence_CLI Home'.
    1 comments copied from page 'Blogging tutorial' to 'Blogging tutorial' in space COPYCLI on target server http://confluence.destinationinstance.com.
    1 labels copied.
    Page 'CLI_Title_1' copied to 'CLI_Title_1' in COPYCLI with parent 'Blogging tutorial'.
    Page 'CLI_Title_2' copied to 'CLI_Title_2' in COPYCLI with parent 'Blogging tutorial'.
    Page 'Confluence_CLI Home' with 5 descendents copied to 'Confluence_CLI Home' in space COPYCLI on target server http://confluence.destinationinstance.com. Page has id 65895.
    6 pages copied.
    Space copied successfully to COPYCLI on http://confluence.destinationinstance.com.
    
    


  • Output in Confluence:

...

  • Image Added


The above action contains the following parameters: 

  • copySpace: Creates a new space and copies pages to the new space. Other information can also be copied based on other parameters. 
  • space: Space key value. For some actions, a space name may also work.
  • targetServer: Target server URL for copy requests.
  • targetUserTarget server user. Defaults to user.
  • nameSpace name or file name for the attachment.
  • descriptionDescriptive text.
  • targetPasswordTarget server user password. Defaults to password.
  • copyLabels: Copy labels when copying a page or space.
  • copyComments: Copy comments when copying a page.
  • descendentsAll descendents for a page.
Info

It is recommended to test this scenario in a non-production environment before implementing it in production environment.