This is a Python script designed to automate the export of all accessible Confluence spaces to Markdown format. It leverages the confluence-markdown-exporter tool and adds the following features:
- Full Space Export: Automatically discovers and iterates through all Confluence spaces accessible to the user.
- Incremental Updates: When run repeatedly, it checks the last modified time of Confluence spaces against local export metadata, only downloading spaces that have been updated, significantly saving time.
- Simple Configuration: Manages all authentication information through a single
config.jsonfile. - Easy to Use: No need to manually execute commands for each space.
- Python 3.8+
- Git
1. Clone the repository
git clone https://github.com/fm365/confluence-exporter.git
cd confluence-exporter2. Create and activate a Python virtual environment
- macOS / Linux
python3 -m venv venv source venv/bin/activate - Windows
python -m venv venv .\venv\Scripts\activate
3. Install dependencies
pip install -r requirements.txt4. Configure authentication
You will need a Confluence API Token (PAT) for authentication.
a. Copy the example configuration file:
cp config.json.example config.jsonb. Edit the config.json file and fill in your details:
{
"confluence": {
"url": "https://your-domain.atlassian.net/wiki",
"user": "[email protected]",
"pat": "YOUR_CONFLUENCE_API_TOKEN_HERE"
},
"jira": {
"url": "https://your-domain.atlassian.net",
"user": "[email protected]",
"pat": "YOUR_JIRA_API_TOKEN_HERE"
}
}url: Your Confluence/Jira instance URL.user: Your login email.pat: Your Personal Access Token. You can create one here.
Note: The
config.jsonfile is ignored by.gitignore, so your secrets will not be committed to the Git repository.
Once configured, simply run the main script:
python export_all_confluence_data.pyThe script will perform the following actions:
- Connect to Confluence and fetch a list of all spaces.
- Create a folder named
data_exportin the project root directory. - Iterate through each space, checking if an update is needed.
- For spaces requiring updates, it calls
confluence-markdown-exporterto export them into separate folders within thedata_exportdirectory. - After successful export, it records the export timestamp for future incremental updates.
This project is licensed under the MIT License.