This article explains usage of copySpace action in Confluence using the Confluence Command Line Interface app.
Instructions
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.
- newSpace: New 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 existing space that has labels, attachments, blogs, comments and permissions to the page(s).
Let's copy a space with spaceKey "CLI" that has following existing parameters to new space with spaceKey "COPY_CLI"Parameters- labels: addpage
- attachments: 2 attachments (pics.jpg and butterfly.jpg)
- blogs: Blog_Title
- comments: comments with user Lucas and admin.
- permissions to the page(s): view permissions to the user Lucas with page 'addPage_CLI'
Execute the following command 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
The result of the above code is as follows:
Output on the terminal:
Output 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:
It is recommended to test this scenario in a test environment before implementing it in production.