中文
GitHub
Docs
Deployment
User Guide
Example
中文
GitHub
Docs
Example
Guest
Sign in
MrDoc User Guide
Basic concepts
MrDoc page description
2.1 Home page
2.2 Collection browsing page
2.3 Document browsing page
2.4 Document editing and modification
2.4.1 Creating a document
2.4.2 Modify document
2.4.3 Create document template
2.4.4 Modify document template
2.4.5 Brief introduction to Markdown syntax
2.4.7 Uploading attachments
2.4.8 Draw a mind map
2.5, Personal Center
2.5.1 Managing documents
2.5.2 Managing collections
2.5.3 Managing document templates
2.5.4 Managing images
2.5.5 Managing user tokens
2.7 Registration and login
2.7.1 User registration
2.7.2 User login
Getting started
Create collection
Create document
Add member collaboration
Documents and knowledge base basics
Collection basic configuration
Pin collection
WebHook message push
Hide collection on homepage
Collection association set
Collection tab configuration
Document editing and content creation
Add document attachments
Show document directory
Create document shortcut
Set document tags
Set document alias
Insert video
Automatic document saving
Document management and organization
Collection directory sorting
Modify document sorting
Subordinate document control
Set document parent-child
Document version history
Transfer collection
Transfer document
Copy document/Move document
Document access records
Collection export and download
Document download and export
Export document PDF
Document drag-and-drop sorting
Collaboration and permission management
Set document permissions
Set collection access permissions
Document copy protection
Set document watermark
Collection collaboration/Collection member management
Document sharing
Collection sharing
Enable document comments
Image and attachment management
Configure image/attachment upload size limit
Configure image upload formats
Configure attachment upload formats/attachment allowlist
Attachment preview
Transfer attachments/Transfer images
Clean up images
Extract attachment text in bulk with the manage command
Data import and migration
Desktop client import
Import Joplin notebooks
Import Evernote
Web import
Command-line import
Web export
Third-party login configuration
DingTalk QR code login and in-app passwordless login configuration
WeCom authentication integration
LDAP authentication integration configuration
OIDC authentication integration
WeChat Official Account web authorization
Third-party storage configuration
MinIO configuration
Qiniu Cloud OSS configuration
Alibaba Cloud OSS configuration
AWS S3 configuration
AI knowledge base and intelligent Q&A
Basic configuration
AI model configuration
Qdrant deployment
Dify framework configuration
Rebuild document AI index
AI features
AI document creation
AI knowledge base Q&A
AI Q&A bot
WeCom smart robot
OnlyOffice integration
Drawio integration
System settings and management
Site information configuration
Homepage template configuration
Official website theme homepage configuration instructions
User and account configuration
Statistics code configuration
Document ads/info blocks/custom head configuration
Disable update detection
Site-wide search mode
Display image thumbnails in documents
Site feedback
RSS subscription
Site single tag settings
Outbound email configuration
Site data export
Editor configuration
Collection documentation page displays site top navigation bar.
Site announcement configuration
Personal account management
Set default editor
Set user nickname
Modify user password
Bind a third-party account
API and developer interfaces
Get user token
Get collection list
Get collection directory
Get collection document list
Get personal document list
Get specified document content
Create new collection
Create a new document
Update documentation
Upload image
Upload attachments
Verify user token
Upload local Office/PDF files as documents
Client and ecosystem integration
Desktop client
Mobile client
Browser extensions
Obsidian plugins
Common usage issues index
Powered by MrDoc Pro
-
+
home
Command-line import
# Command-Line Import # Command-Line Import Tools MrDoc provides a set of command-line import tools for performing import operations directly on the device running MrDoc. For MrDoc deployed via Docker, Docker-Compose, or similar methods, prefix the python command with `docker exec -it <container ID or name>`, for example `docker exec -it mrdoc python manage.py ……`. ## 1. Command Overview | Command | Import Content | Data Source | Repeatable | | --- | --- | --- | --- | | `import_oo_docs` | Local Office / PDF files | Server local directory | No; repeated execution creates duplicate documents | | `import_confluence` | Confluence space pages | Online API / offline HTML export package | Yes; incrementally completed based on the state file | | `import_yuque` | Yuque knowledge base | Online API | Yes; incrementally completed based on the state file | | `import_notion` | Notion page tree | Online API | Yes; incrementally completed based on the state file | | `import_feishu` | Feishu / Lark knowledge space | Online API | Yes; incrementally completed based on the state file | | `import_dingtalk` | DingTalk knowledge base | Online API | Yes; incrementally completed based on the state file | Except for `import_oo_docs`, all other commands share the same set of parameters and execution flow: platform-specific parameters + common parameters. ## 2. Common Parameters (Online Source Import Commands) Applies to `import_confluence`, `import_yuque`, `import_notion`, `import_feishu`, and `import_dingtalk`. ### Syntax ```shell python manage.py import_<platform> [platform-specific parameters] --user <username> [common parameters] ``` ### Common Parameter Description | Parameter | Required | Description | | --- | --- | --- | | `--user` | ✅ Required | The site username to which the imported content belongs; must be an existing user | | `--project` | ⛔ Optional | Import into the specified project ID; if not specified, a new project is created on each execution | | `--project-name` | ⛔ Optional | The name when creating a new project; defaults to the source space name | | `--project-role` | ⛔ Optional | Permission for the new project: 0 public, 1 private, 2 specified users, 3 access code; defaults to 1 private | | `--space` | ⛔ Optional | The identifier of the space / knowledge base to import; separate multiple values with commas; mutually exclusive with `--all-spaces` | | `--all-spaces` | ⛔ Optional | Import all spaces accessible with the current credentials | | `--editor-mode` | ⛔ Optional | Document editor mode: 1 Editormd, 2 Vditor, 3 rich text; defaults to 1 | | `--doc-status` | ⛔ Optional | Document status: 1 published, 0 draft; defaults to 1 | | `--mode` | ⛔ Optional | Repeat import strategy: `skip-existing`, `update`, `create`; defaults to `skip-existing` | | `--no-images` | ⛔ Optional | Do not import images embedded in the body | | `--no-attachments` | ⛔ Optional | Do not import attachments | | `--state-file` | ⛔ Optional | State file path; defaults to `config/<platform>_import_state.json` | | `--limit` | ⛔ Optional | Maximum number of pages to import per space; 0 means no limit | | `--delay` | ⛔ Optional | Interval in seconds before each request, used to throttle the source site | | `--dry-run` | ⛔ Optional | Only inventory and trial conversion; do not write to the database or state file | | `--keep-search-index` | ⛔ Optional | Keep the real-time search index during import (disabled by default to improve batch import speed) | | `--ai-index` | ⛔ Optional | After import completes, enqueue an AI vector index rebuild task for the project | `--mode` semantics: | Value | Behavior | | --- | --- | | `skip-existing` (default) | Already synced in the state file and source version unchanged → skip | | `update` | Even if present in the state file, re-read and sync the body; if content is unchanged, do not write to the database | | `create` | Ignore the state file and always create new documents (causes duplicates; only for one-time migration) | > `--project` and `--mode create` cannot be used together; otherwise an error is reported. Use `update` instead. ### Execution Mechanism - **Without `--project`**: A new project is created on each execution, suitable for trial runs and multi-version comparison. - **With `--project`**: Import into an existing project; combined with the state file, it can be executed repeatedly and only fills in newly added and changed content. - **State file**: Records imported pages (source version number, document ID) and downloaded images and attachments; defaults to `config/<platform>_import_state.json`. Deleting this file forces a full rerun, but existing documents are not automatically deleted. - **Search index**: The real-time search index is paused by default during batch import; after import, run `python manage.py rebuild_index` if search is needed. - **AI index**: For sites with AI Q&A enabled, append `--ai-index` during formal import to enqueue a vector index rebuild task for the newly created project. ### Platform Capability Comparison | Command | Space Identifier | Document Hierarchy | Body Images | Attachments | Document Types Imported Only | | --- | --- | --- | --- | --- | --- | | `import_confluence` | Space key, e.g. `DOC` | ✅ | ✅ | ✅ | Pages | | `import_yuque` | Knowledge base namespace, e.g. `login/repo` | ✅ | ✅ | ❌ | Published regular documents | | `import_notion` | Page ID (32 characters) | ✅ | ✅ | ✅ | Pages (databases not supported) | | `import_feishu` | Knowledge space ID | ✅ | ✅ | ✅ | docx documents | | `import_dingtalk` | Knowledge base workspaceId | ✅ | ✅ | ❌ | DingTalk documents (.adoc) | ## 3. Import Local Office/PDF Documents Command: `import_oo_docs` Used to batch import Office files from a specified directory as Office documents in MrDoc and associate them with a specified project and parent document. ### Syntax ```shell python manage.py import_oo_docs --path <directory path> --user <username> --project <project ID> [--parent_doc <parent document ID>] ``` ### Parameter Description | Parameter | Required | Description | | --- | --- | --- | | `--path` | ✅ Required | The local directory path where the files are located. For example: `D:/office-files/` or `/home/user/docs/` | | `--user` | ✅ Required | The username for creating documents (an existing user in the system) | | `--project` | ✅ Required | The project (document collection) ID to which the documents belong; must be a valid `Project.id` | | `--parent_doc` | ⛔ Optional | The parent document ID for the imported documents; defaults to `0` (directly under the project root) | ### Usage Example ```shell python manage.py import_oo_docs --path /www/wwwroot/office --user mrdoc --project 3 ``` The above command imports Office files from the `/www/wwwroot/office` directory into the project with ID `3`, using the username `mrdoc`. Docker deployment: ```shell docker exec -it mrdoc python manage.py import_oo_docs --path /app/MrDoc/office --user mrdoc --project 3 ``` ### Supported File Formats `.docx`, `.xlsx`, `.pptx`, `.doc`, `.xls`, `.ppt`, `.pdf` (extensions are case-insensitive). ### Processing Rules - Only files in the **first level** of the `--path` directory are processed; subdirectories and other file types in the directory are skipped. - Files are copied to `media/onlyoffice/<year>/<month>/`; if the target file name already exists, suffixes such as `-1`, `-2` are automatically appended without overwriting existing files. - Each file is created as an OnlyOffice document (`editor_mode=7`), with the document title taken from the file name (without extension). - It attempts to extract the text content of the file for site search and content preview; extraction failure does not affect document creation. - This command has no state file, `--dry-run`, or incremental sync; repeated execution creates duplicate documents, so confirm the directory contents before importing. ## 4. Import from Confluence Command: `import_confluence` Migrates Confluence content into MrDoc projects and documents, preserving the page parent-child hierarchy and order, and converting body-embedded images, attachments, and page interlinks to local ones. Two data sources are supported: | Source | `--source` | Description | | --- | --- | --- | | Online API | `api` | Fetched via the Confluence REST API; supports Cloud and Server/DC | | Offline export package | `export` | Parses a Confluence space "HTML export package" (zip); no network required | Quick examples: ```shell # Online import, create a new project each time python manage.py import_confluence --source api --base-url https://xxx.atlassian.net/wiki \ --email me@corp.com --api-token xxx --space DOC --user admin # Import an offline export package into a specified project python manage.py import_confluence --source export --archive D:/DOC-export.zip \ --project 3 --user admin ``` Platform-specific parameters: | Parameter | Description | | --- | --- | | `--source {api,export}` | Required; data source | | `--base-url` | Required for online import; Confluence site address | | `--deployment {auto,cloud,server}` | Deployment type; defaults to `auto`, automatically determined by domain | | `--email` / `--api-token` | Cloud account email and API Token; if Token is not provided, reads the environment variable `CONFLUENCE_API_TOKEN` | | `--token` | Server/DC personal access token; if not provided, reads the environment variable `CONFLUENCE_TOKEN` | | `--username` / `--password` | Server/DC account password authentication | | `--archive` | Required for offline import; path to the space HTML export package (zip) | | `--insecure` | Skip HTTPS certificate verification (for intranet sites with self-signed certificates) | For complete parameters, output description, rerun, and troubleshooting, see [Confluence Migration Import Operation Manual](command_import_confluence.md). ## 5. Import from Yuque Command: `import_yuque` Moves Yuque personal or team knowledge bases entirely into this site. Each knowledge base corresponds to one project, and the knowledge base directory forms the document tree. ### Syntax ```shell python manage.py import_yuque --token <Yuque Token> --space <namespace> --user <username> [common parameters] ``` ### Platform-Specific Parameters | Parameter | Description | | --- | --- | | `--token` | Yuque personal Token; if not provided, reads the environment variable `YUQUE_TOKEN` | | `--api-root` | Yuque API address; defaults to `https://www.yuque.com/api/v2`; for enterprise edition, `https://<enterprise>.yuque.com/api/v2` | | `--insecure` | Skip HTTPS certificate verification | ### Usage Examples ```shell # Import a specified knowledge base (create a new project) python manage.py import_yuque --token xxx --space mylogin/mybook --user admin # Import into an existing project (repeatable; fills in additions/changes) python manage.py import_yuque --token xxx --space mylogin/mybook --project 3 --user admin # Import all knowledge bases visible to the current account python manage.py import_yuque --token xxx --all-spaces --user admin # Inventory only, do not write to the database python manage.py import_yuque --token xxx --space mylogin/mybook --user admin --dry-run ``` ### Notes - `--space` uses the knowledge base namespace in the format `login name/knowledge base path`. - Only published regular documents are imported; other types such as boards, tables, and resources, as well as unpublished drafts, are skipped. - Body images are supported; the Yuque API does not provide attachment download capability, so attachments are not imported. - Group nodes in the directory have no corresponding entity on this site; documents under them are attached to the nearest document ancestor. - The document detail API has rate limits; the command has built-in throttling for detail requests. If rate limiting is still triggered, increase `--delay`. ## 6. Import from Notion Command: `import_notion` Moves the entire Notion page tree into this site. Each accessible top-level page is treated as one project, and its subpages form the document tree. ### Syntax ```shell python manage.py import_notion --token <Notion Token> --space <page ID> --user <username> [common parameters] ``` ### Platform-Specific Parameters | Parameter | Description | | --- | --- | | `--token` | Notion Internal Integration Token; if not provided, reads the environment variable `NOTION_TOKEN` | | `--base-url` | Notion API address; defaults to `https://api.notion.com` | | `--api-version` | `Notion-Version` request header; defaults to `2022-06-28` | | `--insecure` | Skip HTTPS certificate verification | ### Usage Examples ```shell # Import a specified top-level page (create a new project) python manage.py import_notion --token ntn_xxx --space <page ID> --user admin # Import into an existing project (repeatable; fills in additions/changes) python manage.py import_notion --token ntn_xxx --space <page ID> --project 3 --user admin # Import all top-level pages accessible to the integration python manage.py import_notion --token ntn_xxx --all-spaces --user admin # Inventory only, do not write to the database python manage.py import_notion --token ntn_xxx --all-spaces --user admin --dry-run ``` ### Notes - `--space` uses the Notion page ID (the 32-character hexadecimal string in the page link). - The target page must first be "shared" with the integration; otherwise the API returns 404. - Body images and attachments are supported. Notion files are time-limited signed direct links and must be downloaded immediately during import; keep the network stable. - **Databases are not currently supported for migration**; they are skipped with a warning when encountered, and subpages within databases are not imported. - A single page can fetch at most 2000 blocks; excess content is truncated with a warning. ## 7. Import from Feishu / Lark Command: `import_feishu` Moves the entire Feishu knowledge space (wiki) into this site. Each knowledge space corresponds to one project, and the nodes under the space form the document tree. Feishu and Lark have identical APIs; only the domain differs. ### Syntax ```shell python manage.py import_feishu --app-id <AppID> --app-secret <AppSecret> --space <knowledge space ID> --user <username> [common parameters] ``` ### Platform-Specific Parameters | Parameter | Description | | --- | --- | | `--app-id` | Feishu app App ID; if not provided, reads the environment variable `FEISHU_APP_ID` | | `--app-secret` | Feishu app App Secret; if not provided, reads the environment variable `FEISHU_APP_SECRET` | | `--base-url` | Open platform domain; domestic default `https://open.feishu.cn`; for international Lark, pass `https://open.larksuite.com` | | `--web-base-url` | User-side site domain (used to generate source links); defaults to being derived from `--base-url` | | `--insecure` | Skip HTTPS certificate verification | ### Usage Examples ```shell # Import a specified knowledge space (create a new project) python manage.py import_feishu --app-id cli_xxx --app-secret yyy --space <knowledge space ID> --user admin # Import international Lark python manage.py import_feishu --app-id cli_xxx --app-secret yyy \ --base-url https://open.larksuite.com --space <knowledge space ID> --user admin # Import into an existing project (repeatable; fills in additions/changes) python manage.py import_feishu --app-id cli_xxx --app-secret yyy \ --space <knowledge space ID> --project 3 --user admin # Inventory only, do not write to the database python manage.py import_feishu --app-id cli_xxx --app-secret yyy \ --space <knowledge space ID> --user admin --dry-run ``` ### Notes - The app must be granted read permissions for wiki and docx, and the app must be added as a member of the target knowledge space; otherwise the API returns a permission error. - Currently only `docx` documents are supported; Feishu spreadsheets, bitables, mind notes, slides, legacy documents, and other types are skipped with a warning. - Body images and attachments are supported; some embedded objects are marked in the body as not yet supported. ## 8. Import from DingTalk Documents Command: `import_dingtalk` Moves the entire DingTalk knowledge base into this site. Each knowledge base corresponds to one project, and the nodes within the knowledge base form the document tree. ### Syntax ```shell python manage.py import_dingtalk --app-key <AppKey> --app-secret <AppSecret> \ --operator-id <operator unionId> --space <knowledge base ID> --user <username> [common parameters] ``` ### Platform-Specific Parameters | Parameter | Description | | --- | --- | | `--app-key` | DingTalk app AppKey; if not provided, reads the environment variable `DINGTALK_APP_KEY` | | `--app-secret` | DingTalk app AppSecret; if not provided, reads the environment variable `DINGTALK_APP_SECRET` | | `--operator-id` | Operator unionId; if not provided, reads the environment variable `DINGTALK_OPERATOR_ID` | | `--base-url` | DingTalk open platform address; defaults to `https://api.dingtalk.com` | | `--insecure` | Skip HTTPS certificate verification | ### Usage Examples ```shell # Import a specified knowledge base (create a new project) python manage.py import_dingtalk --app-key dingxxx --app-secret yyy \ --operator-id <operator user unionId> --space <knowledge base ID> --user admin # Import into an existing project (repeatable; fills in additions/changes) python manage.py import_dingtalk --app-key dingxxx --app-secret yyy \ --operator-id <operator user unionId> --space <knowledge base ID> --project 3 --user admin # Inventory only, do not write to the database python manage.py import_dingtalk --app-key dingxxx --app-secret yyy \ --operator-id <operator user unionId> --space <knowledge base ID> --user admin --dry-run ``` ### Notes The following limitations all come from the DingTalk API itself: 1. The API requires operating as a certain member; `--operator-id` (the member's unionId) must be provided, and that member must have access to the target knowledge base; 2. Only "DingTalk documents" (`.adoc`) are migrated; other files in the knowledge base (xlsx, pdf, etc.) have no download URL provided by DingTalk and are skipped; 3. The DingTalk block API only returns first-level blocks; nested body content inside containers (callouts, columns) may not be retrievable; 4. Attachments within documents only have opaque identifiers and cannot be downloaded; only the file name is retained in the body. ## 9. Migration Execution Recommendations 1. **Back up the database**: Complete a database backup before formal import. 2. **Trial run first**: For online source commands, first add `--dry-run` to verify that the space, page count, and image/attachment counts meet expectations. 3. **Choose the landing method**: For the first trial run, you may omit `--project` to create a new project; after confirming correctness, specify `--project` for the formal migration. 4. **Execute during off-peak hours**: Import consumes source site API and local IO; it is recommended to execute during business off-peak hours and keep the process uninterrupted. 5. **Incremental rerun**: If interrupted or content is missed, simply repeat the same command (with `--project`); already imported and unchanged content is skipped. 6. **Rebuild indexes**: After import, run `python manage.py rebuild_index`; for sites with AI Q&A enabled, append `--ai-index` or rebuild the AI index separately. 7. **Acceptance**: Check the document tree hierarchy and order, images and attachments, page interlink navigation, and whether site search can find the new content. ## 10. Common Errors and Handling | Message | Handling | | --- | --- | | `用户不存在` | The username specified by `--user` does not exist on the site; create the user first or check the spelling | | `文集不存在` / `文集ID不存在` | The project ID specified by `--project` does not exist; confirm the project ID in the personal center first | | `project参数未设置` | `import_oo_docs` did not pass `--project`; add the project ID | | `源文件目录不存在` | The `--path` path is incorrect, or the directory is not mounted into the container | | `请用 --space 指定空间,或使用 --all-spaces` | No import scope specified | | `未找到任何空间` | The `--space` identifier is incorrect, or the current credentials do not have access to the corresponding space | | `--project 与 --mode create 同时使用会产生重复文档` | Parameter conflict; use `--mode update` instead | | `使用 --source export 时必须提供 --archive` | Confluence offline import is missing the export package path | | `导出包不存在` | The path is incorrect or the file was not uploaded to the server | | `使用 --source api 时必须提供 --base-url` | Confluence online import is missing the site address | | Credential verification failure (401/403, etc.) | Check whether the Token, AppID/AppSecret, and operatorId are valid, as well as app permissions and space membership | | Some attachments failed to be stored | The default site policy only allows zip attachments; allow the required formats in "System Settings → Document Settings → Attachment Formats" and rerun | > When deployed with Docker, paths such as `--path`, `--archive`, and `--state-file` refer to paths **inside the container**; mount or copy the files into the container first.
mrdoc
Dec. 4, 2026, 11:32 a.m.
Forward
Favorites
Last
Next
Scan the QR Code
Copy link
Scan the QR code to share.
Copy link
share
link
type
password
Update password
Validity period
Markdown file
Word document
PDF document (print)