The Confluence Export Tool v2.0 provides an interactive command-line interface for selectively exporting Confluence pages with meaningful content (HTML, Markdown) and comprehensive error handling.
- π― Interactive Page Selection: Choose specific pages to export rather than exporting everything
- π Multiple Content Formats: Export as HTML, Markdown, or both
- β‘ Rate Limiting: Intelligent API rate limiting with exponential backoff
- π Progress Tracking: Real-time progress bars and detailed statistics
- π‘οΈ Error Handling: Comprehensive error reporting with retry logic
- π Export Index: Optional index file with export metadata
- πΎ Smart Caching: Local page cache for instant startup (24-hour TTL)
- π Pagination: Browse large spaces 25 pages at a time
- π Chronological Sorting: Pages sorted by last modified date (newest first)
npm installSet up your environment variables in a .env file:
CONFLUENCE_BASE_URL=https://your-domain.atlassian.net
CONFLUENCE_EMAIL=your-email@domain.com
CONFLUENCE_API_TOKEN=your-api-token
SPACE_KEY=YOUR_SPACE_KEY- Go to Atlassian Account Settings
- Click "Create API token"
- Give it a label and copy the token
- Use this token as your
CONFLUENCE_API_TOKEN
npm startThis will:
- Fetch all pages from your Confluence space
- Present an interactive list for page selection
- Allow you to configure export options
- Export selected pages with progress tracking
Export all pages without prompts:
npm start -- --no-interactive| Option | Description | Default |
|---|---|---|
--dev |
Enable development mode with verbose logging | false |
--output <dir> |
Output directory | ./output |
--concurrency <number> |
Max concurrent downloads (1-10) | 5 |
--no-interactive |
Disable interactive mode (export all pages) | false |
--all-pages |
Export all pages (not blog posts) without user input - exports as markdown and HTML, skips attachments | false |
--format <format> |
Content format: both, html, markdown, storage |
both |
--no-attachments |
Skip downloading attachments | false |
--no-index |
Skip creating index file | false |
--clear-cache |
Clear the page cache before starting | false |
--cache-info |
Show cache information and exit | false |
npm startnpm start -- --no-interactive --format markdownnpm start -- --all-pagesnpm start -- --devnpm start -- --output ./my-export --concurrency 2npm start -- --no-attachments --no-index# Show cache information
npm start -- --cache-info
# Clear cache and refresh data
npm start -- --clear-cache
# Force refresh without interactive cache choice
npm start -- --clear-cache --no-interactiveWhen running in interactive mode, you'll see:
- Page List: All pages in your space, sorted alphabetically
- Special Options:
- β Select All Pages
- β Cancel Export
- Search/Filter: Use arrow keys and space to select pages
- Confirmation: Review your selection before export
Choose from:
-
Content Format:
- Both HTML and Markdown
- HTML only
- Markdown only
- Raw Confluence storage format
-
Options:
- Include attachments (recommended)
- Create export index file
- Set concurrency level
output/
βββ export-index.json # Export metadata and page index
βββ pages/
βββ 123456-Page-Title/
β βββ Page-Title-metadata.json # Page metadata
β βββ Page-Title.html # HTML content (if selected)
β βββ Page-Title.md # Markdown content (if selected)
β βββ attachments/ # Page attachments (if enabled)
β βββ image1.png
β βββ document.pdf
βββ 789012-Another-Page/
βββ Another-Page-metadata.json
βββ Another-Page.html
βββ Another-Page.md
The tool now includes a sophisticated caching system to dramatically improve startup times:
- First Run: Fetches all pages from Confluence (takes time) and caches them locally
- Subsequent Runs: Loads from cache instantly (under 1 second vs 30+ seconds)
- Cache Location:
./output/.cache/pages-cache.json - Cache TTL: 24 hours (automatically expires)
- Automatic: Tool asks if you want to use cache or refresh on each run
- Manual: Use
--cache-infoto check cache status - Clear: Use
--clear-cacheto force refresh - Smart: Cache includes modification dates for accurate chronological sorting
- β‘ 99% faster startup for large spaces (1500+ pages)
- π Automatic expiration ensures data freshness
- πΎ Minimal storage - only essential page metadata cached
- π― Perfect for browsing - immediate access to paginated page lists
The tool implements several strategies to handle Confluence API limitations:
- Minimum 100ms between requests
- Exponential backoff on rate limit errors
- Automatic retry with increasing delays
- Clear communication when rate limits are hit
- Comprehensive error reporting for each page
- Continues export even if individual pages fail
- Detailed error summary at the end
- Specific guidance for common issues (auth, permissions, etc.)
- Real-time progress bar with ETA
- Current page being processed
- Success/error indicators
- Final statistics with timing information
β Export failed: Request failed with status code 401
Solution: Check your credentials:
- Verify
CONFLUENCE_EMAILandCONFLUENCE_API_TOKEN - Ensure your API token hasn't expired
- Test with:
curl -u email:token https://your-domain.atlassian.net/wiki/rest/api/space
β Export failed: Request failed with status code 403
Solution: Check permissions:
- Ensure your account has read access to the space
- Verify your API token has appropriate scopes
- Contact your Confluence admin if needed
β Export failed: Request failed with status code 404
Solution: Check configuration:
- Verify
SPACE_KEYis correct (case-sensitive) - Ensure
CONFLUENCE_BASE_URLis correct - The space exists and you have access to it
β οΈ Rate limited. Waiting 60 seconds...
Solution: This is normal behavior. The tool will:
- Automatically wait as requested by the API
- Continue the export after the wait period
- You can reduce
--concurrencyto make fewer parallel requests
If exported pages appear empty (like your Landing Pages example):
- The page might genuinely be empty in Confluence
- Check if the page has content in the Confluence web interface
- Some pages might only have metadata without body content
- Start Small: Test with a few pages first using interactive mode
- Monitor Rate Limits: Use
--concurrency 2for large exports - Enable Dev Mode: Use
--devflag when troubleshooting - Check Permissions: Ensure you have read access to all desired pages
- Regular Backups: Run exports regularly to maintain up-to-date backups
You can override any configuration with environment variables:
export MAX_CONCURRENCY=2
export OUTPUT_DIR=./custom-output
export RETRY_ATTEMPTS=5
npm startFor automated exports (CI/CD, scheduled tasks):
# Non-interactive export with error handling
npm start -- --no-interactive --format both --output ./exports/$(date +%Y-%m-%d) || exit 1You can also use the tool programmatically:
const { ConfluenceExporter } = require('./src/confluence-exporter');
const { Config } = require('./src/config');
async function customExport() {
const config = new Config();
config.loadFromEnv();
const exporter = new ConfluenceExporter(config, {
contentFormat: 'markdown',
includeAttachments: false
});
// ... implement custom logic
}For issues and questions:
- Check the troubleshooting section above
- Run with
--devflag for detailed error information - Verify your Confluence permissions and API token
- Check the export statistics for specific error details
The tool provides comprehensive error reporting to help diagnose and resolve issues quickly.