Versions Compared

Key

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

This article explains usage of copySpace action using the Confluence Command Line Interface. 

...

For this scenario, use the copySpace action with space and newSpace as required parameters and name, description, findReplace, copyBlogs, copyAttachments, copyLabels, copyComments, copyPermissions and continue as optional parameters where: 

  • copySpace: Creates a new space and copies pages to the new space. Other information can be copied as well based on other parameters. By default, find replace logic applies only to content. To also apply find replace logic to the title, use --options applyFindReplaceOnTitles.
  • space: Space key. For some actions, a space name may also work.
  • newSpaceNew space key for copied or moved page.
  • name: Space name or file name for attachment.
  • description: Descriptive text.
  • findReplace: Successively find and replace matching text with the find and replace values specified using find:replace syntax. The first colon (:) delineates the find value from the replace value. Single quote values containing a color and then escape embedded quotes. Deprecated use is a comma separated list of the same. Recommend using multiple parameters instead. The deprecated use case is only valid when the multiple parameter feature is not being used.
  • copyBlogs: Copy blogs when copying a space.
  • copyAttachments: Copy attachments when copying a page.
  • copyLabels: Copy labels when copying a page or space.
  • copyComments: Copy comments when copying a page
  • copyPermissions: Copy permissions when copying a page or space. Source permissions replace existing target permissions. Note Confluence page permissions are really done as restrictions.
  • continue: Continue processing even after errors are encountered for run actions. Also used for some action to ignore certain errors like not found errors on remove actions.

        
For this example,

...

ensure that there is an existing space that has labels, attachments, blogs, comments and permissions to the page(s).

  1. Copy a space with space key, CLI, that has following parameters, to new space with space key COPY_CLI:

    Panel
    titleParameters
    1. labels: addpage
    2. attachments: 2 attachments (pics.jpg and butterfly.jpg)
    3. blogs: Blog_Title
    4. comments: comments with user Lucas and admin.
    5. permissions to the page(s): view permissions to the user Lucas with page 'addPage_CLI'

    Image Modified

  2. Execute the following command on the terminal:

    Code Block
    themeMidnight
    --action copySpace --space "CLI" --newSpace "COPYCLI" --name "CopySpace_CLI" --description "Creation of CopySpace_CLI" --copyBlogs --copyAttachments --copyLabels --copyComments --copyPermissions --findReplace "Create:CREATE_FIND_REPLACE" --continue


  3. The result of the above code is as follows:
  • Output on the terminal:

    Code Block
    themeMidnight
    titleOutput on the terminal:
    --action copySpace --space "CLI" --newSpace "COPYCLI" --name "CopySpace_CLI" --description "Creation of CopySpace_CLI" --copyBlogs --copyAttachments --copyLabels --copyComments --copyPermissions --findReplace "Create:CREATE_FIND_REPLACE" --continue
    
    
    Space added with key COPYCLI, name 'CopySpace_CLI', and url http://localhost:8704/display/COPYCLI.
    3 space permissions copied from space CLI to space COPYCLI. 
    Page 'Confluence_CLI Home' copied to 'Confluence_CLI Home' in COPYCLI.
    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.
    1 labels copied.
    Page 'addPage_CLI' copied to 'addPage_CLI' in COPYCLI with parent 'Confluence_CLI Home'.
    Attachment 'pics.jpg' copied to 'addPage_CLI' in space COPYCLI.
    Attachment 'butterfly.jpg' copied to 'addPage_CLI' in space COPYCLI.
    2 attachments copied from page 'addPage_CLI' to 'addPage_CLI' in space COPYCLI.
    2 comments copied from page 'addPage_CLI' to 'addPage_CLI' in space COPYCLI.
    1 labels copied.
    3 page permissions copied from page 'addPage_CLI' in space CLI to page 'addPage_CLI' in space COPYCLI. Permissions were replaced.
    Page 'CLI_Title_1' copied to 'CLI_Title_1' in COPYCLI with parent 'addPage_CLI'.
    Page 'CLI_Title_2' copied to 'CLI_Title_2' in COPYCLI with parent 'addPage_CLI'.
    Page 'CLI_Title_3' copied to 'CLI_Title_3' in COPYCLI with parent 'addPage_CLI'.
    Page 'Confluence_CLI Home' with 5 descendents copied to 'Confluence_CLI Home' in space COPYCLI. Page has id 13172763.
    6 pages copied.
    Blog 'Blog_Title' copied to 'Blog_Title' in space COPYCLI. Blog has id 13172776. Posting date was 2020-04-08.
    1 blogs copied.
    Space copied successfully to COPYCLI.


  • Output in Confluence:

    Image Modified


Info

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

...