No description
  • Python 98.3%
  • HTML 1.7%
Find a file
2026-01-31 15:53:57 +00:00
Templates feat: Introduce Trilium templates for Docker stacks, containers, and host documentation, including their JSON definitions and a setup README. 2026-01-31 15:51:14 +00:00
.gitignore feat: Add initial Python script to synchronize Portainer stack information with Trilium notes, including configuration, dependencies, and documentation. 2026-01-31 14:54:45 +00:00
config.json.example feat: Add initial Python script to synchronize Portainer stack information with Trilium notes, including configuration, dependencies, and documentation. 2026-01-31 14:54:45 +00:00
PortainerSync.py feat: add Host Documentation Template to the list of resolved templates 2026-01-31 15:53:57 +00:00
README.md feat: Add initial Python script to synchronize Portainer stack information with Trilium notes, including configuration, dependencies, and documentation. 2026-01-31 14:54:45 +00:00
requirements.txt chore: update project dependencies in requirements.txt 2026-01-31 15:07:15 +00:00

Portainer to Trilium Sync

This script synchronizes Docker Stacks from a Portainer instance to Trilium Notes. It creates a structured hierarchy of notes for each stack, including the docker-compose.yml file, .env variables, and service details.

Features

  • Automated Sync: Fetches all stacks from Portainer API.
  • Trilium Integration: Creates/Updates notes in Trilium using the ETAPI.
  • Templates: Applies "Docker Stack Template" and "Docker Container Template" to notes.
  • Host Grouping: Automatically groups stacks under a note named after the current hostname.
  • Metadata: Syncs metadata such as Last Updated, Portainer ID, and Ports.
  • File Sync: Syncs docker-compose.yml and .env files as code notes.

Configuration

The script uses config.json for configuration.

config.json

{
    "trilium_url": "https://trilium.example.com",
    "etapi_token": "YOUR_TRILIUM_ETAPI_TOKEN",
    "parent_note_id": "YOUR_PARENT_NOTE_ID",
    "portainer_url": "https://portainer.example.com",
    "portainer_token": "YOUR_PORTAINER_ACCESS_TOKEN",
    "sync_env_files": true
}
  • trilium_url: The base URL of your Trilium instance.
  • etapi_token: Your Trilium ETAPI token (Settings -> Options -> ETAPI).
  • parent_note_id: The Note ID under which "Portainer Stacks" will be created.
  • portainer_url: Base URL of your Portainer instance.
  • portainer_token: Portainer Access Token (My account -> Access tokens).
  • sync_env_files: Set to true to sync .env variables from Portainer.

Setup & Requirements

  1. Create and Install Virtual Environment:

    The script relies on a Python virtual environment.

    python3 -m venv venv
    ./venv/bin/pip install -r requirements.txt
    

Usage

  1. Ensure config.json is configured.
  2. Run the script using the virtual environment:
./venv/bin/python PortainerSync.py

Test Mode

You can run the script in test mode to append -portainer to the hostname (e.g., hostname-portainer). This allows you to verify the sync without modifying your production documentation tree.

./venv/bin/python PortainerSync.py --test

Migration from Old Script

This script replaces the file-system based Sync_Script.py. It uses the Portainer API directly instead of scanning a local directory of compose files.