How Do I replace all 'hard' links to my old Base URL

Still need help?

The Atlassian Community is here for you.

Ask the community

Purpose

When changing the Base URL, either due to a URL change or from an export/import (e.g. Cloud to Server or Server to Server) absolute links to the old Base URL need to be changed.

Example Server to Server

Old Base URL http://mycompany.com/confluence
New Base URL http://confluence.mycompany.com/

Example Cloud to Server (this requires extra steps)

Old Base URL http://mycompany.atlassian.net/wiki
New Base URL http://confluence.mycompany.com/

Please note that Cloud to Server Base URL change requires extra steps due to these known issues

Resolution

Please do these changes in a test environment first.

Please make sure you have a backup of your production environment.


Export and Import Option

Either create a full site export, or full text database dump and perform a find/replace or sed to change the old Base URL to the new Base URL.

(warning) Site export and imports have performance issues on large instances and will not change the URL in page history.

(warning) Database export and import will make changes to page history.

Generate export file

Full site export

  1. Go to > General Configuration > Backup & Restore
  2. Check Back up attachments
  3. Click Back Up
  4. Find the xmlexport file (usually) in <confluence-home>/temp
  5. Extract the entities.xml file from the xmlexport file
  6. Shut down Confluence

Database export

Use a native database tool to export all the data. This requires Confluence to be shut down.

  • For MySQL use mysqldump
  • For PostgreSQL use pg_dump

Replace Old Base URL to New Base URL

For Cloud exports only ...

Cloud exports will use the entities.xml file for the backup zip

  1. For CONFSERVER-54759 - Getting issue details... STATUS
    Replace all content URLs to Confluence Server format with this command (using the example URLs above)

    sed -r -e 's/mycompany\.atlassian\.net\/wiki\/spaces\/[A-Z0-9]+\/pages\/([0-9]+)\/[A-Za-z0-9+.]+/confluence.mycompany.com\/pages\/viewpage.action?pageId=\1/g' entities.xml
  2. For CONFSERVER-45919 - Getting issue details... STATUS
    Replace incorrect Base URL entry from N/A

    sed -r -e 's/<server\.base\.url>N\/A</server\.base\.url>/<server.base.url>http://confluence.mycompany.com</server.base.url>/g' entities.xml

This example uses the site export file entities.xml, if doing a database export replace this file with export.sql)

sed -r -e 's/mycompany\.com\/confluence/confluence.mycompany.com/g' entities.xml

Reimport

Full site export

Using this option will require extra steps to re-load all the Add-ons from http://marketplace.atlassian.com/

  1. Re-zip up the xmlexport file, taking care to place the files in the same location
  2. Go to > General Configuration > Backup & Restore
  3. Click Choose file and select the new xmlbackup xip file
  4. Click Upload and Restore

Database import

Use the database tools to re-import the data.

WebDAV option

Use the WebDAV plugin and mount the WebDAV location locally, then run a script that uses sed to replace all of the Old Base URLs. This option will not replace content in historical pages, and will create a new page version for all pages that are changed (this includes any page versions that are crawled and edited).

Last modified on Jan 12, 2018

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.