Currently Confluence does not support renaming or copying spaces through the user interface. You may wish to vote towards these feature requests:
Use The Copy Space Plugin
The best option is to install the Copy Space Plugin.
Note that this plugin is still in beta release, and is not officially supported by Atlassian.
Read the developer's notes in the Atlassian blogs.
Manually Clone Or Rename A Space
Alternatively, it is possible to manually clone or rename a space by modifying an XML backup of the target space.
Notes
- May require manually updating external links to that space.
- The instructions have been confirmed for Confluence 2.2 onwards. Users running older versions are recommended to upgrade Confluence before continuing.
- Where examples are given, they involve changing oldkey:Old Space Name into newkey:New Space Name. You need to substitute your own keys for oldkey and newkey, and your own space names for Old Space Name and New Space Name.
- When importing a space export for a space that already exists, the previous space content will be overwritten.
- Read the process in full before beginning.
Stage 1: Rename Space
- Select a new, unique space key and name for the second space. Space keys may only consist of ASCII letters or numbers (A-Z, a-z, 0-9) and no empty spaces are allowed in the key.
- Clone your production Confluence instance to a test server on another computer now. (For instructions, see Migrating Confluence Between Servers.) You should now have a production server and test server both containing the same data and can avoid the risk of corrupting your production Confluence instance.
- On the test server, login as an administrator.
- Go to Browse Space -> Advanced -> Export Space and export the target space as XML including attachments.
- Save the space backup.
- Open the space backup file with a zip file editor and find the file entities.xml.
- Edit entities.xml in a text editor.
- Do a 'Search & Replace' on the old space name as shown below. Swap out Old Space Name and New Space Name for the actual names.
| Search For |
Replace With |
| [CDATA[Old Space Name] |
[CDATA[New Space Name] |
- Do a 'Search' for any occurrences of the old space name that occur in user content. You may wish to replace some or all of these references with the new space name. Replace Old Space Name and New Space Name with the actual names.
| Search For |
| Old Space Name |
- Do four 'Search & Replaces' on each of the references to the old space key as shown below. Swap out oldkey and newkey for your actual keys.
| Search For |
Replace With |
| [oldkey] |
[newkey] |
| spaceKey=oldkey |
spaceKey=newkey |
| [oldkey: |
[newkey: |
| key=oldkey] |
key=newkey] |
For example:
Space name : Test Space
Space key : test
New space name : Test Space 2
New space key : test2
The above search and replace ensures that you will change the test oldkey to test2, and change the "Test Space* Old Space Name to Test Space 2.
- Save the modified entities.xml.
- Overwrite the original entities.xml in the space backup with the modified version.
- Login to the test instance as a Confluence administrator.
- Go to Administration -> Backup & Restore. Under 'Upload a zipped backup to Confluence', browse to select to the modified space backup. Check the 'Build index' option and select 'Upload & Restore'.
- Once the restore process has completed, access the new space and test that you can access pages, embedded links and attachments. Any error in this step indicates that your search and replace was performed incorrectly and you should to retry from step 2.
Stage 2: Restore On Production
- Backup your production instance now.
- Login to the production instance as a Confluence administrator.
- Go to Administration -> Backup & Restore. Under 'Upload a zipped backup to Confluence', browse to select to the modified space backup. Check the 'Build index' option and select 'Upload & Restore' If any data loss occurs as a result of using this workaround, immediately revert to the backup.
- Once the restore process has completed, access the new space and test that you can access pages, embedded links and attachments. If any error occurs during this step, revert to the site backup.
- If renaming a space, you can delete the old space by going to Browse Space -> Space Admin -> Remove Space. Click OK to remove the old space.
Stage 3: Rename Space References
Links in other spaces to the old space will remain unchanged. If you are renaming a space, you will need to change these links to point to the new space. Users who are copying a space can leave the links pointing to the original space by skipping this stage.
Changing these links depends on if you want to change every link, or only some. If not all links must be changed or you are unwilling to stop your production instance, this must be done by editing each page individually. If all links must be changed, follow the instructions below.
- Create a site XML backup including attachments from Administration -> Backup & Restore.
- Save the site XML backup file.
- Stop the production instance.
- Create two copies of the site backup. Keep one copy as the original, unmodified backup, the other will be modified. Rename the backups so that it is clear which is being modified.
- Open the copy for modification and edit entities.xml.
- Do four 'Search & Replaces' on each of the references to the old space key as shown below. Swap out oldkey and newkey for the actual keys
| Search For |
Replace With |
| [oldkey] |
[newkey] |
| spaceKey=oldkey |
spaceKey=newkey |
| [oldkey: |
[newkey: |
| key=oldkey] |
key=newkey] |
- Save the updated entities.xml back into the modified site XML backup file
- Start the production instance
- Import the modified site XML backup from Administration -> Backup & Restore. If you have any problems, revert to the original unmodified backup and redo the links manually instead
Done.
Related
Copy Space Template: There is a feature request being tracked at CONF-4538.
Comments (9)
Jul 12, 2007
James Mortimer says:
Comment on a simpler process: We also find it useful to use the webdav interf...Comment on a simpler process:
Clarification question on details above:
Jul 12, 2007
Ivan Benko says:
James, could you please help me out and do the following: 1. Provide more detail...James, could you please help me out and do the following:
1. Provide more details re WEBDAV interface to copy space templates?
2. Link to the PErl xml-rpc program to check it out
I'd like to investigate it as a potential alternative.
As per the changes to the metadata, I do not believe there are any as only the space key is being changes to a new unique value. Furhter those plugins store the data independently in the osproperty table. Yet please do hesitate to inform me should there be any problems, mate.
Oct 12
James Mortimer says:
A search of confluence documentation reveals: WebDAV Confluence WebDAV Plugin...A search of confluence documentation reveals:
WebDAV
Remote API
Other
Jul 14
Tomi Strugar says:
Help please! I am trying to copy Space templates to another Space. I've used...Help please! I am trying to copy Space templates to another Space. I've used Windows Explorer and also the WebDav client "AnyClient" to connect successfully to my wiki but the only folders I see in the space where the templates are is: Home, @News, TS1, and a file called name_of_my_space.txt. Where are the Space templates and the Global templates stored? Thanks!
Jul 15
Tony Cheah Tong Nyee says:
Hi Tomi, To my understanding, copying content from one space to another via the...Hi Tomi,
To my understanding, copying content from one space to another via the WebDAV client could only migrate the contents (such as pages, news and attachments). To my understanding, you meant to say the template as outlined in the following link?
If that is the case, the templates are being stored in Confluence database's BANDANA table.
Hope it helps.
Cheers,
Tony
Aug 18, 2007
neeraj says:
How can i retreive the SpaceKey from SpaceName what is code for that stuff for...How can i retreive the SpaceKey from SpaceName
what is code for that stuff
for example : Spacekey value = $method(SpaceName)
Aug 21, 2007
Choy Li Tham says:
Hi Neeraj, You can try using the following sample: Spacekey value = $space.key...Hi Neeraj,
You can try using the following sample:
Spacekey value = $space.key
For more information on the methods used, please see:http://www.atlassian.com/software/confluence/docs/api/latest/
Regards,
Choy Li
Aug 27, 2007
steve picton says:
Hi James Having inherited a set of instructions for this process I noted that ...Hi James
Having inherited a set of instructions for this process I noted that mine are different to yours.
My instructions specifically state "Update the first occurrence only" when referring to the lines :
<property name="name"><![CDATA[Test Space]]></property>
<property name="key"><![CDATA[test]]></property>
Also there is no mention in my instuctions of changing any other occurrences of the "SpaceName" or the "SpaceKey" in the entities file.
Would this possibly explain why my "SpaceTemplate" entities file has reached over 20meg with no space content?RegardsSteve Picton
Jul 16
Donna Hrynkiw says:
Tip for someone else who might end up with a similar problem: Confluence is rel...Tip for someone else who might end up with a similar problem:
Confluence is relatively new to my company. I am the admin on two Confluence sites -- our production site, and my personal desktop site.
I exported a space on the production site to XML, including all pages. Using the directions above, I modified the entities.xml file and imported the space to my desktop site. Of all the pages in the space, half did not show up on the desktop site. Whazzup with that?
(Skipping about 45 minutes of thrashing...) Despite having confluence-administrators membership on both sites, I was not able to see all the documents in the imported space because the view privs on the "missing" files were set for a group that did not exist on my desktop site. Once I added the group to my desktop site and my desktop admin account to the new group, I was able to see all the pages.
Add Comment