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. 

Instructions

...

  • copySpaceCreates 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).

...

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 Removed

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

...

Output on the terminal:

...

themeMidnight
titleOutput on the terminal:

...

This article explains how to copy a space in the same instance using the Confluence Command Line Interface. 

Instructions

Use the copySpace action to copy a space. with space and newSpace as required parameters    

  1. Executing the below action copies the current space, CLI, to new space, COPYCLI.

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


    Image Added




    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 --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 .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.
    23 page attachmentspermissions copied from page 'addPage_CLI' in space CLI to page 'addPage_CLI' in space COPYCLI. 2Permissions commentswere copiedreplaced.
    fromPage page 'addPageCLI_Title_CLI1' copied to 'addPageCLI_Title_CLI1' in COPYCLI space COPYCLI.
    1 labels copied.
    3 page permissions copied from pagewith parent 'addPage_CLI'.
    Page 'CLI_Title_2' copied to 'CLI_Title_2' in COPYCLI with parent 'addPage_CLI'.
    in space CLIPage 'CLI_Title_3' copied to page 'addPageCLI_Title_CLI3' in space COPYCLI. Permissionswith were replacedparent 'addPage_CLI'.
    Page 'CLI_Title_1'Confluence_CLI Home' with 5 descendents copied to 'CLI_Title_1Confluence_CLI Home' in space COPYCLI with parent 'addPage_CLI'.
    Page 'CLI_Title_2. Page has id 13172763.
    6 pages copied.
    Blog 'Blog_Title' copied to 'CLIBlog_Title_2' in space COPYCLI. Blog withhas 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 Removed
    id 13172776. Posting date was 2020-04-08.
    1 blogs copied.
    Space copied successfully to COPYCLI.


  • Output in Confluence:

    Image Added


The above action contains the following parameters: 

  • copySpaceCreates 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.
  • 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.


Info

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

...