Confluence でスペースのコピーまたは名前変更を行う方法

要約

This guide provides some workarounds if you need to rename a space in Confluence. 

Confluence Cloud, Server, and Data Center do not provide a method for copying a space or changing the space key.

(lightbulb) Since the CONFSERVER-3191 - Easily create a copy of an entire space is fixed with Confluence 8.3, we now have a built-in functionality for copying a space.

制限事項

Apart from the built-in method that is introduced with Confluence 8.3, the information on this page is provided for informational purposes only, and will not be directly supported by Atlassian, should you wish to pursue possible workarounds in light of this limitation.

このページの情報は最新ではない可能性があり、本番環境に適用する前に入念なテストを行う必要があります

Solution 1 - Use built-in 'Copy Space' functionality

Available for DATA CENTER

The best option is to use the built-in functionality that is introduced with Confluence 8.3. This functionality can help you copy a space:

Note that this method does not copy the history of Pages and Blogposts. Please check the ' What will be copied from a space? ' section of the mentioned KB article.

Alternative - Use an app from the Atlassian Marketplace

Available for CLOUD, DATA CENTER

Similar to the above, there are other options in our Atlassian Marketplace. Third-party apps can have some extended functionalities that may fulfill your business requirement better than the built-in. Examples:

ソリューション 2 - ページ階層のコピー機能を使う

Available for CLOUD, DATA CENTER

The ability to copy a page and all its child pages was introduced in Confluence 6.0.  This can be useful if you need to copy the contents of an entire space. 

The following instructions are for the Confluence Server or Data Center, but you can follow a similar process in Cloud. 

ページ階層のコピー機能を使ってスペースをコピーする方法は、次のとおりです。

  1. 新しいスペースを作り、任意の権限、ルックアンドフィール、その他のカスタマイズを設定します。 

  2. 元のスペースで、[スペース ツール] > [ページの並べ替え] に移動し、スペースの root に存在するページをホーム ページの子ページに一時的に移動させます。これは、リンクはマクロなどのページ間のつながりがコピー時に失われないようにするためです。root にページが存在しない場合はこの手順をスキップしてかまいません。 

  3. スペースのホーム ページで、 > [コピー] を選択します。

  4. 宛先として先ほどの新しいスペースを指定します。

  5. [子ページを含める] を選択します。

  6. ラベル、添付ファイル、制限が保持されるよう、すべてのチェックボックスが選択されているのを確認します。

  7. [コピー] を選択します。スペースのサイズによっては少し時間がかかる可能性があります。ページはバッチ単位でコピーされるため、即座にすべてのデータが揃わない可能性があります。

  8. 元のスペースに戻り、一時的に動かしたページをスペースの root に戻します。
  9. 新しいスペースで、コピーしたページは新しいスペースの既存のホームページの子ページになります。[スペース ツール] > [ページの並べ替え] に移動し、コピーしたページをスペースの root に移動して、ホームページの子ページではなくなるようにします。

  10. [スペース ツール] > [概要] に移動し、コピーしたホームページをスペースのホームページに設定します。

  11. 不要なホームページを削除します。

  12. ホームページの子ページにしたくないページ (ライブラリなど) をスペースの root に戻します。

Note that this feature will not preserve the page history, likes, or comments of the source pages.

このプロセス全体を短い動画でご確認いただけます。 

他のスペースからの受信リンクは引き続き元のスペースを参照する点にご注意ください。 

ソリューション 3 - スペースをエクスポートして XML を変更する

Available for CLOUD, DATA CENTER

ターゲット スペースの XML バックアップを変更して、スペースを手動でクローンしたり名前変更したりすることができます。 

Please be aware of following points while working with this Solution.

  • この内容を本番環境に適用する前に、サイトのバックアップを作成し、変更をステージング環境でテストするようにしてください。 
  • This procedure can cause the issue described in the following bugs:
    • CONFSERVER-78062 - Jira Link doesn't appear/show count after import space
    • CONFSERVER-60357 - Confluence pages aren't referenced under "Mentioned in" in Jira after space restore
  • If you're changing the space key in order to import it into your Atlassian Confluence Cloud site, make sure you'll do it on a space-by-space basis. Atlassian Confluence Cloud does not support a full site import.

複数のスペースの名前変更を同時に行う場合、インスタンス全体のエクスポートを行うほうが作業を簡単に行える場合があります。サイトのフル エクスポートを行う場合、exportDescriptor.properties ファイルの変更は不要で、次のファイルでスペース キーを変更する必要があります。

<export_folder>/plugin-data/com.atlassian.activeobjects.confluence.spi/activeObjectsBackupRestoreProvider.pdata

完全なサイト バックアップは Confluence にインポートしたときに問題を発生させることがあるため、インポートをステージング環境のサーバーで最初にテストすることを強く推奨します。問題が発生する場合はスペース単位の方法を利用するようにします。

Stage 1: Generate the XML backup and create a test instance

  1. 2 つ目のスペース用に、一意の新しいスペース キーと名前を用意します。スペース キーではASCII 文字と数字のみ (A-Z、a-z、0-9) を利用できます。キーでは空白文字、特殊文字、アンダースコアは利用できません。スペース キーに無効な文字が含まれている場合、再インポートは失敗し、スタック トレースが記録されます。
  2. ご利用の本番 Confluence インスタンスを、別のコンピュータ上のテスト サーバーに一時的に複製します (手順については、「本番環境をテスト インスタンス に復元する」をご参照ください)。これで、本番サーバーとテスト サーバーに同じデータを用意し、本番 Confluence インスタンスのデータが破損した場合のリスクを軽減することができました。
  3. テスト サーバーで、管理者としてログインします。
  4. [スペース] > [スペース ツール] > [コンテンツ ツール] > [エクスポート] > [XML] > [次へ] > [完全なエクスポート] > [スペースのエクスポート] に移動し、対象のスペースを、添付ファイルを含む XML としてエクスポートします。



  5. スペースのバックアップを保存します。

ステージ 2: entities.xml ファイルを編集する (Bash&PowerShell スクリプト経由、または手動)

スクリプト

If using the Bash script, then  skip   Stage 3: Edit the exportDescriptor.properties file step.

If using the PowerShell script, then execute Stage 3: Edit the exportDescriptor.properties file step.

If using any of the two scripts, then skip the Stage 6: Rename Space References step.

# variables (all uppercase except for 'old_space_key' and 'old_space_name', Supply them as they are; there's no need to change them to uppercase or lowercase—keep them as they are.)
zipfile="<path/myfile.zip>"
oldkey_uppercase="<OLD SPACE KEY>"
oldname_uppercase="<OLD SPACE NAME>"
newkey_uppercase="<NEW SPACE KEY>"
newname_uppercase="<NEW SPACE NAME>"
old_space_key="<Actual Space Key>"
old_space_name="<Actual Old Space Name>"
# from here on, no changes are needed
# the variables defined above will be used below

# the lower case variables will be defined here based on the above, and you do not need to change them
oldkey_lowercase=$(echo "${oldkey_uppercase}" | tr [:upper:] [:lower:])
oldname_lowercase=$(echo "${oldname_uppercase}" | tr [:upper:] [:lower:])
newkey_lowercase=$(echo "${newkey_uppercase}" | tr [:upper:] [:lower:])
newname_lowercase=$(echo "${newname_uppercase}" | tr [:upper:] [:lower:])

# unzipping the all the file like entities.xml,exportDescriptor.properties and attachments
unzip ${zipfile};

# commands to actually edit the entities.xml and exportDescriptor.properties files
sed -i "s/\[CDATA\[${oldname_uppercase}\]/\[CDATA\[${newname_uppercase}\]/g" entities.xml; 
sed -i "s/\[CDATA\[${old_space_name}\]/\[CDATA\[${newname_lowercase}\]/g" entities.xml; 
sed -i "s/\[CDATA\[${oldname_lowercase}\]/\[CDATA\[${newname_lowercase}\]/g" entities.xml;
sed -i "s/\[CDATA\[${oldkey_uppercase}\]/\[CDATA\[${newkey_uppercase}\]/g" entities.xml;
sed -i "s/\[CDATA\[${old_space_key}\]/\[CDATA\[${newkey_lowercase}\]/g" entities.xml;
sed -i "s/\[CDATA\[${oldkey_lowercase}\]/\[CDATA\[${newkey_lowercase}\]/g" entities.xml;

sed -i "s/spaceKey:${oldkey_uppercase}/spaceKey:${newkey_uppercase}/g" entities.xml;
sed -i "s/spaceKey:${old_space_key}/spaceKey:${newkey_lowercase}/g" entities.xml;

# For latest Version of Confluence 
sed -i "s|<property name=\"key\">${oldkey_uppercase}|<property name=\"key\">${newkey_uppercase}|g" entities.xml
sed -i "s|<property name=\"key\">${oldkey_lowercase}|<property name=\"key\">${newkey_uppercase}|g" entities.xml;
sed -i "s|<property name=\"key\">${old_space_key}|<property name=\"key\">${newkey_uppercase}|g" entities.xml;
sed -i "s|<property name=\"lowerKey\">${oldkey_lowercase}|<property name=\"lowerKey\">${newkey_lowercase}|g" entities.xml;
sed -i "s|<property name=\"lowerKey\">${oldkey_uppercase}|<property name=\"lowerKey\">${newkey_lowercase}|g" entities.xml;
sed -i "s|<property name=\"lowerKey\">${old_space_key}|<property name=\"lowerKey\">${newkey_lowercase}|g" entities.xml;
sed -i "s|<property name=\"name\">${oldname_uppercase}|<property name=\"name\">${newname_uppercase}|g" entities.xml;
sed -i "s|<property name=\"name\">${oldname_lowercase}|<property name=\"name\">${newname_uppercase}|g" entities.xml;
sed -i "s|<property name=\"name\">${old_space_name}|<property name=\"name\">${old_space_name}|g" entities.xml;

sed -i "s|<spaceKey>${oldkey_uppercase}|<spaceKey>${newkey_uppercase}|g" entities.xml;

sed -i "s|<property name=\"context\">${oldkey_uppercase}|<property name=\"context\">${newkey_uppercase}|g" entities.xml;


sed -i "s/spaces\/${oldkey_uppercase}/spaces\/${newkey_uppercase}/g" entities.xml;
sed -i "s/spaces\/${old_space_key}/spaces\/${newkey_lowercase}/g" entities.xml;


sed -i "s/spaceKey=${oldkey_uppercase}/spaceKey=${newkey_uppercase}/g" exportDescriptor.properties;
sed -i "s/spaceKey=${old_space_key}/spaceKey=${newkey_lowercase}/g" exportDescriptor.properties;

sed -i "s/spaceKeys=${oldkey_uppercase}/spaceKey=${newkey_uppercase}/g" exportDescriptor.properties;
sed -i "s/spaceKeys=${old_space_key}/spaceKey=${newkey_lowercase}/g" exportDescriptor.properties;

sed -i "s/spacekey=${oldkey_uppercase}/spacekey=${newkey_uppercase}/g" entities.xml;
sed -i "s/spacekey=${old_space_key}/spacekey=${newkey_lowercase}/g" entities.xml;

sed -i "s/ri:space-key=\"${oldkey_uppercase}\"/ri:space-key=\"${newkey_uppercase}\"/g" entities.xml;
sed -i "s/ri:space-key=\"${old_space_key}\"/ri:space-key=\"${newkey_lowercase}\"/g" entities.xml;

sed -i "s/ri:space-key=${oldkey_uppercase}/ri:space-key=${newkey_uppercase}/g" entities.xml;
sed -i "s/ri:space-key=${old_space_key}/ri:space-key=${newkey_lowercase}/g" entities.xml;

sed -i "s/<ac:parameter ac:name=\"spaces\">${oldkey_uppercase}<\/ac:parameter>/<ac:parameter ac:name=\"spaces\">${newkey_uppercase}<\/ac:parameter>/g" entities.xml;
sed -i "s/<ac:parameter ac:name=\"spaces\">${old_space_key}<\/ac:parameter>/<ac:parameter ac:name=\"spaces\">${newkey_lowercase}<\/ac:parameter>/g" entities.xml;

sed -i "s/<ac:parameter ac:name=\"spaceKey\">${oldkey_uppercase}<\/ac:parameter>/<ac:parameter ac:name=\"spaceKey\">${newkey_uppercase}<\/ac:parameter>/g" entities.xml;
sed -i "s/<ac:parameter ac:name=\"spaceKey\">${old_space_key}<\/ac:parameter>/<ac:parameter ac:name=\"spaceKey\">${newkey_lowercase}<\/ac:parameter>/g" entities.xml;


sed -i "s/\"parentPageSpaceKey\":\"${oldkey_uppercase}\"/\"parentPageSpaceKey\":\"${newkey_uppercase}\"/g" entities.xml;
sed -i "s/\"parentPageSpaceKey\":\"${old_space_key}\"/\"parentPageSpaceKey\":\"${newkey_lowercase}\"/g" entities.xml;

sed -i "s/spacekey=${oldkey_lowercase}/spacekey=${newkey_lowercase}/g" entities.xml;
sed -i "s/spacekey=${old_space_key}/spacekey=${newkey_lowercase}/g" entities.xml;

sed -i "s/spacekey=${oldkey_lowercase}/spacekey=${newkey_lowercase}/g" entities.xml;
sed -i "s/spacekey=${old_space_key}/spacekey=${newkey_lowercase}/g" entities.xml;

# zipping the updated entities.xml and exportDescriptor.properties files back into the zip file
zip -ur ${zipfile} entities.xml exportDescriptor.properties attachments; 

When implementing the above step, OS X users might encounter the following issue: Error when using 'sed' with 'find' command on OS X: "invalid command code ." See linked community discussion for possible solutions.

$inputOldKeyL = "oldname"
$inputNewKeyL = "newname"
$exportFolder = "path_to_export_folder"

$oldKeyL = $inputOldKeyL.ToLower()
$newKeyL = $inputNewKeyL.ToLower()
$oldKeyU = $oldKeyL.ToUpper()
$newKeyU = $newKeyL.ToUpper()

$fileIn = Join-Path $exportFolder "entities.xml"
$fileOut = Join-Path $exportFolder "entities2.xml"

$fileContent = [System.IO.File]::ReadAllText($fileIn)
$afterReplace = $fileContent.
Replace("<property name=`"lowerDestinationSpaceKey`"><![CDATA[$oldKeyL]]></property>", "<property name=`"lowerDestinationSpaceKey`"><![CDATA[$newKeyL]]></property>").
Replace("<property name=`"lowerKey`">![CDATA[$oldKeyL]]></property>", "<property name=`"lowerKey`">![CDATA[$newKeyL]]></property>").
Replace("[$oldKeyU]", "[$newKeyU]").
Replace("[$oldKeyL]", "[$newKeyL]").
Replace("spaceKey=$oldKeyU", "spaceKey=$newKeyU").
Replace("spaceKey=$oldKeyL", "spaceKey=$newKeyL").
Replace("[$oldKeyU`:", "[$newKeyU`:").
Replace("key=$oldKeyU]", "key=$newKeyU]").
Replace("<spaceKey>$oldKeyU</spaceKey>", "<spaceKey>$newKeyU</spaceKey> ").
Replace("ri:space-key=`"$oldKeyU`"", "ri:space-key=`"$newKeyU`"").
Replace("ri:space-key=$oldKeyU", " ri:space-key=$newKeyU").
Replace("<ac:parameter ac:name=`"spaces`">$oldKeyU</ac:parameter>", "<ac:parameter ac:name=`"spaces`">$newKeyU</ac:parameter>").
Replace("<ac:parameter ac:name=`"spaceKey`">$oldKeyU</ac:parameter>", "<ac:parameter ac:name=`"spaceKey`">$newKeyU</ac:parameter>")
[System.IO.File]::WriteAllText($fileOut, $afterReplace)
Rename-Item -Path $fileIn -NewName "entities_old.xml"
Rename-Item -Path $fileOut -NewName "entities.xml"

Alternative Powershell script:

$inputOldKeyL = "<OLD_SPACE_KEY>"
$inputNewKeyL = "<NEW_SPACE_KEY>"
$exportFolder1 = "C:\<PATH>\entities.xml"
$exportFolder2 = "C:\<PATH>\exportDescriptor.properties"
$oldKeyL = $inputOldKeyL.ToLower()
$newKeyL = $inputNewKeyL.ToLower()
$oldKeyU = $oldKeyL.ToUpper()
$newKeyU = $newKeyL.ToUpper()
Write-Host $oldKeyU
Write-Host $newKeyU
Write-Host $oldKeyL
Write-Host $newKeyL
(Get-Content -Path $exportFolder1) |
    ForEach-Object {$_ -creplace $oldKeyL, $newKeyL} |
	ForEach-Object {$_ -creplace $oldKeyU, $newKeyU} |
        Set-Content -Path $exportFolder1
(Get-Content -Path $exportFolder2) |
    ForEach-Object {$_ -creplace $oldKeyL, $newKeyL} |
	ForEach-Object {$_ -creplace $oldKeyU, $newKeyU} |
        Set-Content -Path $exportFolder2

手動

  1. zip ファイル エディタを使用してスペース バックアップ ファイルを開き、 entities.xml ファイルを見つけます。
  2. テキスト エディタで entities.xml を編集します。
  3. 次のように、古いスペース名の検索および置換を行います。Old Space NameNew Space Name を実際のキーで置き換えます。

    検索対象

    置換先

    [CDATA[Old Space Name]

    [CDATA[New Space Name]

  4. ユーザー コンテンツで古いスペース名が存在するすべての箇所を検索します。必要に応じて、これらの一部またはすべてを新しいスペース名で置き換えます。Old Space NameNew Space Name を実際の名前で置き換えます。

    検索対象

    Old Space Name

  5. 次のように、スペース キーのパターンの検索および置換を行います。

     大文字と小文字が区別されることにご注意ください。プレースホルダーのOLDKEY /NEWKEY は、大文字または大文字と小文字が混在するキーを表し、oldkey/newkey は、すべてが小文字のキーを表します。

    検索対象

    置換先

    OLDKEY

    NEWKEY

    spaceKey=OLDKEY

    spaceKey=NEWKEY

    [OLDKEY:

    [NEWKEY:

    key=OLDKEY]

    key=NEWKEY]

    <spaceKey>OLDKEY</spaceKey>

    <spaceKey>NEWKEY</spaceKey>

    ri:space-key="OLDKEY"

    ri:space-key="NEWKEY"

    (warning) この手順は、名前を変更するスペース内のリンクが元のスペース キーではなく新しいスペース キーを参照する必要がある場合に実行します。それ以外の場合はスキップします。

    ri:space-key=OLDKEY

    ri:space-key=NEWKEY

    (warning) この手順は、名前を変更するスペース内のリンクが元のスペース キーではなく新しいスペース キーを参照する必要がある場合に実行します。それ以外の場合はスキップします。

    <ac:parameter ac:name="spaces">OLDKEY</ac:parameter>

    <ac:parameter ac:name="spaces">NEWKEY</ac:parameter>

    <ac:parameter ac:name="spaceKey">OLDKEY</ac:parameter>

    <ac:parameter ac:name="spaceKey">NEWKEY</ac:parameter>

    <property name="lowerDestinationSpaceKey"><![CDATA[NEWKEY]]></property>


    <property name="lowerDestinationSpaceKey"><![CDATA[newkey]]></property>

    (warning) Beware new key is used on both sides


    <property name="lowerKey"><![CDATA[NEWKEY]]></property>


    <property name="lowerKey"><![CDATA[newkey]]></property>

    (warning) Beware new key is used on both sides


    <property name= "lowerKey"><![CDATA[oldkey]]></property>

    <property name= "lowerKey"><![CDATA[newkey]]></property>

    spaceKey=OLDKEY

    spaceKey=NEWKEY

    spacekey=oldkey

    spacekey=newkey

  6. 変更した entities.xml を保存します。
  7. スペース バックアップ内の元の entities.xml を、変更済みのバージョンで置き換えます。

ステージ 3: exportDescriptor.properties ファイルの編集

  1. exportDescriptor.properties ファイルを任意のテキスト エディタで編集します。
  2. exportDescriptor.properties ファイルの spaceKey の値を 新しいスペース キーに変更します。

ステージ 4: 検証のために下位の (テスト/開発/ステージング) 環境に復元する

  1. Confluence 管理者としてテスト インスタンスにログインします。
  2. Go to Administration menu  > General Configuration > Backup & Restore. Under 'Upload a zipped backup to Confluence', browse to select the modified space backup. Check the 'Build index' option and select 'Upload & Restore'.
  3. 復元プロセスが完了したら、新しいスペースにアクセスし、ページ、内部リンク、および添付ファイルにアクセスできることを確認します。この段階でエラーが発生する場合、検索および置換が適切に行われていないため、ステップ 2 から再度やり直す必要があります。

ステージ 5: スペースを本番環境にインポート

  1. 本番環境インスタンスのバックアップを作成します。
  2. Confluence 管理者として本番環境インスタンスにログインします。
  3. Go to Administration menu  > General Configuration > Backup & Restore. Under 'Upload a zipped backup to Confluence', browse to select 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.
  4. 復元プロセスが完了したら、新しいスペースにアクセスし、ページ、内部リンク、および添付ファイルにアクセスできることを確認します。この段階でエラーが発生した場合、サイト バックアップに戻す必要があります。
  5. スペースの名前変更を行う場合、[スペース] > [スペース ツール] > [概要] > [スペースの削除] で、古いスペースを削除できます。[OK] をクリックして古いスペースを削除します。

ステージ 6: スペース参照の名前変更

ほかのスペース内にある、古いスペースへのリンクは変更されずに残ります。スペースの名前変更を行う場合、これらのリンクが新しいスペースを参照するように変更する必要があります。スペースをコピーする場合、この段階をスキップして、リンクが元のスペースを参照するようにすることもできます。

これらのリンクの変更は、すべてのリンクを変更するか、一部のみを変更するかに応じて異なります。すべてのリンクを変更する必要がない場合や、本番環境インスタンスを停止したくない場合は、各ページを手動で変更する必要があります。すべてのリンクを変更する必要がある場合、次の手順をご利用ください。

  1. Create a site XML backup including attachments from Administration menu  > General Configuration > Backup & Restore.
  2. サイトの XML バックアップ ファイルを保存します。
  3. 本番環境インスタンスを停止します。
  4. サイト バックアップのコピーを 2 つ作成します。1 つのコピーを、オリジナルの未変更のバックアップとして保持し、もう片方を変更します。変更対象を確認できるよう、バックアップの名前を変更します。
  5. 変更用のコピーを開いて entities.xml を編集します。
  6. 次のように、古いスペース キーを参照する検索および置換を 4 回行います。oldkeynewkey を実際のキーで置き換えます。

    検索対象

    置換先

    [oldkey]

    [newkey]

    spaceKey=oldkey

    spaceKey=newkey

    [oldkey:

    [newkey:

    key=oldkey]

    key=newkey]

  7. 更新した entities.xml を、変更した XML サイト バックアップ ファイルに保存します。
  8. 本番環境を開始します。
  9. Import the modified site XML backup from Administration menu  > General Configuration > Backup & Restore. If you have any problems, revert to the original unmodified back up and redo the links manually instead

最終更新日: 2025 年 1 月 23 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.