Self-Hosting·7 min read·

Paperless-ngx Document Archiving: Automated OCR and Metadata Extraction

Transform paper files into a searchable digital archive with Paperless-ngx on Ubuntu, tuning Tesseract OCR, Celery workers, and email intake.

NB

Netbay Cloud Team

Netbay Engineering

On this page

Physical paper invoices, legal contracts, receipts, and tax records create organizational clutter and are impossible to search effectively. Paperless-ngx is an open-source document management system that transforms physical paperwork into a searchable digital archive. It provides automated document consumption via scanner network shares, mobile uploads, and IMAP email inboxes, extracting text using Tesseract Optical Character Recognition (OCR) and cataloging documents with machine-learning auto-tagging.

Running Paperless-ngx on an Ubuntu Linux VPS with dedicated Intel Xeon Platinum cores and High-Speed SSD storage allows rapid multi-page OCR processing without stalling web interactions.

Architecture of Paperless-ngx

Paperless-ngx relies on four primary components:

  1. **Webserver**: The Django application serving the search UI and REST API.
  2. **Celery Worker**: Asynchronous background queue processing CPU-heavy tasks: PDF rasterization, image deskewing, and OCR.
  3. **Valkey**: In-memory message broker managing Celery task queues.
  4. **PostgreSQL**: Stores document metadata, extracted OCR text, correspondents, and document types.

Docker Compose Setup on Ubuntu 24.04

Create the application directories:

bash
mkdir -p /srv/paperless && cd /srv/paperless
mkdir -p data media export consume

Create docker-compose.yml:

yaml
# /srv/paperless/docker-compose.yml
services:
  broker:
    image: valkey/valkey:8-alpine
    restart: unless-stopped
    volumes:
      - valkeydata:/data

  db:
    image: postgres:16-alpine
    restart: unless-stopped
    environment:
      POSTGRES_DB: paperless
      POSTGRES_USER: paperless
      POSTGRES_PASSWORD: SecurePaperlessPassword2026
    volumes:
      - pgdata:/var/lib/postgresql/data

  webserver:
    image: ghcr.io/paperless-ngx/paperless-ngx:latest
    restart: unless-stopped
    depends_on:
      - db
      - broker
    ports:
      - "8000:8000"
    volumes:
      - ./data:/usr/src/paperless/data
      - ./media:/usr/src/paperless/media
      - ./export:/usr/src/paperless/export
      - ./consume:/usr/src/paperless/consume
    env_file: docker-compose.env

volumes:
  pgdata:
  valkeydata:
Expand
Paperless-ngx Document Archive
Paperless-ngx OCR Archiving Pipeline

Tuning the Tesseract OCR Pipeline

Configure the environment settings in docker-compose.env to optimize OCR language models, worker threads, and automated email polling:

ini
# /srv/paperless/docker-compose.env
PAPERLESS_REDIS=redis://broker:6379
PAPERLESS_DBHOST=db
PAPERLESS_DBNAME=paperless
PAPERLESS_DBUSER=paperless
PAPERLESS_DBPASS=SecurePaperlessPassword2026

# OCR and language optimization
PAPERLESS_OCR_LANGUAGE=eng+hin
PAPERLESS_OCR_MODE=skip
PAPERLESS_OCR_CLEAN=clean
PAPERLESS_OCR_DESKEW=true
PAPERLESS_OCR_ROTATE_PAGES=true

# Multi-threaded worker tuning for Intel Xeon
PAPERLESS_TASK_WORKERS=2
PAPERLESS_THREADS_PER_WORKER=2

# Security and storage
PAPERLESS_SECRET_KEY=CryptographicallySecureRandomSecretKey2026
PAPERLESS_URL=https://docs.example.com
PAPERLESS_FILENAME_FORMAT={created_year}/{correspondent}/{title}

Setting PAPERLESS_OCR_MODE=skip instructs Paperless to extract embedded digital text directly when available, running Tesseract OCR only on scanned raster images to save CPU cycles.

Launch Paperless-ngx and create the initial administrator:

bash
sudo docker compose up -d
sudo docker compose exec webserver python3 manage.py createsuperuser
Paperless-ngx Ingestion & OCR Architecture Document Intake - /consume directory - IMAP email attachments - Mobile REST upload - High-Speed SSD watch Instant file detection Tesseract OCR & ML - Unpaper image deskew - Multi-lang OCR (eng+hin) - Celery task queue - Auto-tagging classifier Intel Xeon Platinum Searchable Archive - PDF/A archival storage - PostgreSQL full-text index - Clean directory naming - Sub-second search hits Lucknow DC01 Automated OCR and metadata classification converts paper clutter into indexed PDF/A records
Self-Hosting Document Management, Archiving, and OCR Systems
YouTube

Automated Document Ingestion Testing

Test automated document ingestion by dropping a test PDF file into the consume directory:

bash
# Copy test document to consume directory
cp invoice-sample.pdf /srv/paperless/consume/

# Monitor ingestion and OCR extraction progress
sudo docker compose logs -f webserver

Paperless-ngx detects the file within seconds, strips skew, extracts text, assigns tags, and stores the searchable PDF/A asset.

Deploy your private Paperless-ngx document archive on Netbay Linux VPS in under 60 seconds with High-Speed SSD in Lucknow DC01 — netbayhosts.in.

Keep reading

Follow along on a real VPS

Deploy Linux in under 60 seconds

These guides are written against Ubuntu, Debian, and RHEL-family images — the same ones on NetBay.

Deploy an instance