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
- Executing the below action copies the current space, CLI, to new space, COPYCLI.
--action copySpace --space "CLI" --newSpace "COPYCLI" --name "CopySpace_CLI" --description "Creation of CopySpace_CLI" --copyBlogs --copyAttachments --copyLabels --copyComments --copyPermissions --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 --continue Space added with key COPYCLI, name 'CopySpace_CLI', and url http://acli2.examplegear.com/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:
The above action contains the following parameters:
- 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.
- 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.
It is recommended to test this scenario in a test environment before implementing it in production.