Bulk Find and Replace Content in Confluence Cloud
プラットフォームについて: Cloud のみ - この記事は クラウド プラットフォームのアトラシアン製品に適用されます。
要約
Confluence Cloud does not currently provide a native user interface for performing bulk "find and replace" operations across multiple pages or spaces.
This can make site-wide updates—such as updating server names in macros, rebranding text, or migrating URLs—a significant manual effort.
問題の説明
When infrastructure changes occur (e.g., changing a company domain or updating macro parameters), references embedded in Confluence pages may become outdated or broken. Manually editing hundreds of pages to update these references is time-consuming.
Pending feature requests:
- CONFCLOUD-26979 - 課題情報を取得中... ステータス
- CONFCLOUD-35900 - 課題情報を取得中... ステータス
- CONFCLOUD-77189 - 課題情報を取得中... ステータス
- CONFCLOUD-77957 - 課題情報を取得中... ステータス
- CONFCLOUD-81446 - 課題情報を取得中... ステータス
- CONFCLOUD-83244 - 課題情報を取得中... ステータス
ソリューション
There are a few ways to handle bulk content updates:
Custom API Solution: Develop a script using the Confluence Cloud REST API to automate the identification and replacement of strings within page storage format.
Marketplace Apps: Utilize third-party apps designed for link management or bulk updates.
Partner Solution: For complex scenarios, you may also consult the Atlassian Partner Directory to engage experts who can build and execute a custom strategy for you.
Backup and "Undo" Strategy
Rather than attempting to update the entire site at once, consider planning and executing changes on a per-space basis. This allows for better validation and minimizes the impact if a script requires adjustment.
Before performing any bulk updates, ensure you have a recovery plan:
Space Backups: Perform a export of the space's content to CSV for each target space before running your script.
Store Original Content: When using the API, consider adding a step in your script to store the original
storageformat locally before sending the update. This provides a quick reference for an "undo" operation.Version History: Updates made via the API automatically create a new page version. If an error occurs, you can manually restore a page content from the page history.
Custom API Steps
The following steps outline the programmatic workflow to find and replace URLs, macro parameters, or text strings across your site.
1. Enable Admin Key
To ensure your script can access and modify all content (including pages with view or edit restrictions), you must use the Admin Key. This feature is available for Premium and Enterprise plans.
API: Admin Key API
Requirement: Include the Admin Key header in every subsequent API call.
'Atl-Confluence-With-Admin-Key': true
2. Identify the Scope
You can Download a spaces report to get a list of all Space IDs in your site to use as a starting point for your script.
3. List Pages in Space
For each target space, retrieve the list of pages to iterate through.
API: Pages in Space API
4. Fetch Page Content
Retrieve the current content body for each page. It is recommended to request the storage format (XHTML-based), as this makes it easier to identify specific macro parameters and link tags compared to other formats.
- API: Get Page by Id API
Recommendation: Store this original storage format locally before proceeding to the next step. This acts as a manual "undo" backup should you need to revert the content to its exact prior state.
5. Transform Content (Find and Replace)
Perform the string replacement or regex operations on the storage format retrieved in the previous step.
Logic: Identify the target URLs, macro parameters, or text strings and replace them with the new values.
Validation: If you are updating macros, ensure the structure remains valid to prevent rendering issues.
Recommendation: Before running a script, manually edit a single page to understand the "before" and "after" states of your target content. Then, use the Get Page by Id API to view the storage format for both versions. This will help you understand the exact structure you need to target for your find-and-replace logic.
6. Push Updated Content
After replacing the target strings, send the modified body back to Confluence. You must include the current version number (incremented by 1) to successfully update the page.
API: Update Page API
Marketplace Options
The following Marketplace apps offer specialized bulk-editing and broken link detection features:
Link Fixing Only
Atlassian Partner Directory
If your organization requires a custom solution but does not have the internal development resources to build and maintain a script, you can engage an Atlassian Partner. Partners are certified experts who can assist with complex migrations, custom API development, and site-wide content updates.
Atlassian Partner Directory — Search for a partner by location, service type, or product expertise to help build and execute a tailored strategy for your environment.
Troubleshooting & Considerations
- Rate Limiting: Confluence Cloud APIs are subject to Confluence Cloud API rate limiting. Ensure your script includes retry logic or delays.
Macro Syntax: When updating macros, be careful to maintain the correct XML/storage format structure to avoid breaking the macro rendering.
Dry Run: It is highly recommended to run your script against a single test page or a trial site before executing it across your production environment.
免責事項
Please note that the custom solutions and Marketplace apps mentioned above are provided as options for your consideration and do not constitute official recommendations.
There may be other apps available on the Atlassian Marketplace that also meet your requirements.
We strongly recommend testing any solution in a non-production environment first.