This service synchronizes documents, tags, and correspondents from Paperless-NGX to Notion databases.
- Syncs documents with metadata (title, date, correspondent, tags)
- Syncs tags with their properties
- Syncs correspondents
- Handles document updates and deletions
- Uploads original document files to Notion
- Incremental updates (only syncs changed items)
- Archives documents in Notion when deleted from Paperless-NGX
- Configurable sync interval
- Docker support for easy deployment
- A running Paperless-NGX instance
- A Notion account with:
- A Notion integration (for API access)
- Three databases set up for Documents, Tags, and Correspondents
-
Clone this repository
-
Copy the environment file:
cp config/.env.example config/.env
-
Edit
config/.env
and fill in your configuration:PAPERLESS_URL
: Your Paperless-NGX instance URLPAPERLESS_TOKEN
: Your Paperless-NGX API tokenNOTION_TOKEN
: Your Notion integration tokenNOTION_DOCUMENTS_DB
: Notion database ID for documentsNOTION_TAGS_DB
: Notion database ID for tagsNOTION_CORRESPONDENTS_DB
: Notion database ID for correspondentsSYNC_INTERVAL
: Sync interval in seconds (default: 3600)LOG_LEVEL
: Logging level (default: INFO)
Create three databases in Notion with the following properties:
- Title (title)
- paperless_id (number)
- Created Date (date)
- Added Date (date)
- Correspondent (relation to Correspondents database)
- Tags (relation to Tags database)
- File (files & media) - Stores the actual document PDF/file from Paperless-NGX
- Archived (checkbox) - Indicates if the document was deleted in Paperless-NGX
- Name (title)
- paperless_id (number)
- Color (text)
- Name (title)
- paperless_id (number)
-
Make sure Docker and Docker Compose are installed
-
Build and start the service:
docker-compose up -d
-
Check the logs:
docker-compose logs -f
-
Install Python 3.11 or later
-
Install dependencies:
pip install -r requirements.txt
-
Run the service:
python src/main.py
The service creates a sync.log
file with detailed logging information. The log file is rotated daily and kept for 7 days.
- Check the logs in
sync.log
- Verify your environment variables in
config/.env
- Ensure your Paperless-NGX instance is accessible
- Verify your Notion integration has access to the databases
The service handles different scenarios as follows:
-
New Documents: When a new document is added to Paperless-NGX, it's created in Notion with all its metadata and the original file.
-
Updated Documents: When a document is modified in Paperless-NGX (metadata or file), the corresponding Notion page is updated.
-
Deleted Documents: When a document is deleted from Paperless-NGX, the corresponding Notion page is marked as "Archived" instead of being deleted. This preserves the document history while indicating it's no longer active.