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

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問


目的

このガイドは、Confluence のスペースをコピーしたり名前変更したりする必要がある場合の回避策をご案内します。 

Confluence Cloud、Server、および Data Center では、スペースのコピーやスペース キーの変更を行うための方法は提供されていません。次の機能リクエストが起票されています。 

T キー 要約 ステータス
Loading...
Refresh

制限事項

このページの内容は、この制限の回避策をお探しのお客様向けに情報提供を目的として提供されており、アトラシアンによる直接サポートの対象外です

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

ソリューション 1 - Atlassian Marketplace のアプリを使う

対象 クラウド サーバー DATA CENTER

もっとも推奨されるオプションは、スペースのコピー機能を提供しているいずれかのサードパーティ アプリを使用することです。例:

Atlassian Labs の Copy Space for Confluence アプリは、Confluence Server および Data Center 7.0 以降との互換性を持たない点にご注意ください。  

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

対象 クラウド サーバー 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. 

次の手順は Confluence Server または Data Center 向けのものですが、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, like or comments of the source pages.


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

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

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

対象 クラウド サーバー DATA CENTER

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

この内容を本番環境に適用する前に、サイトのバックアップを作成し、変更をステージング環境でテストするようにしてください。 

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

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

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

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.

ステージ 1: XML バックアップを生成してテスト インスタンスを作成する

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



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

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

スクリプト

Bash スクリプトを使う場合、ステージ 3: exportDescriptor.properties ファイルの編集ステップはスキップします。

PowerShell スクリプトを使う場合、ステージ 3: exportDescriptor.properties ファイルの編集ステップを実行します。

2 つのスクリプトのいずれかを使う場合、ステージ 6: スペース参照の名前変更の手順をスキップします。



bash
# variables (all upper case)
zipfile="<path/myfile.zip>"
oldkey_uppercase="<OLD SPACE KEY>"
oldname_uppercase="<OLD SPACE NAME>"
newkey_uppercase="<NEW SPACE KEY>"
newname_uppercase="<NEW 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 only the entities.xml and the exportDescriptor.properties files
unzip ${zipfile} entities.xml exportDescriptor.properties;

# 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\[${oldname_lowercase}\]/\[CDATA\[${newname_lowercase}\]/g" entities.xml;
sed -i "s/\[CDATA\[${oldkey_uppercase}\]/\[CDATA\[${newkey_uppercase}\]/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=${oldkey_uppercase}/spaceKey=${newkey_uppercase}/g" exportDescriptor.properties;
sed -i "s/spacekey=${oldkey_uppercase}/spacekey=${newkey_uppercase}/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=${oldkey_uppercase}/ri:space-key=${newkey_uppercase}/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=\"spaceKey\">${oldkey_uppercase}<\/ac:parameter>/<ac:parameter ac:name=\"spaceKey\">${newkey_uppercase}<\/ac:parameter>/g" entities.xml;
sed -i "s/\"parentPageSpaceKey\":\"${oldkey_uppercase}\"/\"parentPageSpaceKey\":\"${newkey_uppercase}\"/g" entities.xml;
sed -i "s/spacekey=${oldkey_lowercase}/spacekey=${newkey_lowercase}/g" entities.xml;

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

上記の手順を実行するときに OS X を使っていると、次の問題が発生する場合があります。Error when using 'sed' with 'find' command on OS X: "invalid command code ." ソリューションについてはコミュニティのディスカッションをご確認ください。

PowerShell
$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"


手動


  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) 検索元と置換先の両方で新しいキーが使用されることにご注意ください。


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


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

    (warning) 検索元と置換先の両方で新しいキーが使用されることにご注意ください。


    <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  >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  > 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  > 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  > General Configuration > Backup & Restore. If you have any problems, revert to the original unmodified back up and redo the links manually instead


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

最終更新日: 2022 年 12 月 30 日

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

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