This is an automated archive made by the Lemmit Bot.
The original was posted on /r/selfhosted by /u/zen-afflicted-tall on 2025-03-08 04:44:56+00:00.
Today I managed to setup paperless-ngx -- the self-hosted document scanning management system -- and got it running with Docker Compose, a local filesystem backup process, and even integrated it with my HP Officejet printer/scanner for automated scanning using node-hp-scan-to.
I thought I'd share my docker-compose.yml
with the community here that might be interested in a similar solution:
Example Docker Compose file for paperless-ngx (https://github.com/paperless-ngx/paperless-ngx)
To setup on Linux, MacOS, or WSL - run the following commands:
- mkdir paperless && cd paperless
- Create docker-compose.yml
- Copy and paste the contents below into the file, save and quit
- Back in the Terminal, run the following commands:
- echo "PAPERLESS_SECRET_KEY=$(openssl rand -base64 64)" > .env.paperless.secret
- docker compose up -d
- In your web browser, browse to: http://localhost:8804/
- Your "consume" folder will be in ./paperless/consume
volumes: redisdata:
services: paperless-broker: image: docker.io/library/redis:7 restart: unless-stopped volumes: - redisdata:/data
paperless-webserver: image: ghcr.io/paperless-ngx/paperless-ngx:latest restart: unless-stopped depends_on: - paperless-broker ports: - "8804:8000" volumes: - ./db:/usr/src/paperless/data - ./media:/usr/src/paperless/media - ./export:/usr/src/paperless/export - ./consume:/usr/src/paperless/consume env_file: .env.paperless.secret environment: PAPERLESS_REDIS: redis://paperless-broker:6379 PAPERLESS_OCR_LANGUAGE: eng
Automate daily backups of the Paperless database and assets:
paperless-backup: image: alpine:latest restart: unless-stopped depends_on: - paperless-webserver volumes: - ./db:/data/db:ro - ./media:/data/media:ro - ./export:/data/export:ro - ./backups:/backups command: > /bin/sh -c ' apk add --no-cache tar gzip sqlite sqlite-dev && mkdir -p /backups && while true; do echo "Starting backup at $$(date)" BACKUP_NAME="paperless_backup_$$(date +%Y%m%d_%H%M%S)" mkdir -p /tmp/$$BACKUP_NAME
# Create a consistent SQLite backup (using .backup command)
if [ -f /data/db/db.sqlite3 ]; then
echo "Backing up SQLite database"
sqlite3 /data/db/db.sqlite3 ".backup /tmp/$$BACKUP_NAME/db.sqlite3"
else
echo "SQLite database not found at expected location"
fi
# Copy important configuration files
cp -r /data/db/index /tmp/$$BACKUP_NAME/index
cp -r /data/media /tmp/$$BACKUP_NAME/
# Create compressed archive
tar -czf /backups/$$BACKUP_NAME.tar.gz -C /tmp $$BACKUP_NAME
# Remove older backups (keeping last 7 days)
find /backups -name "paperless_backup_*.tar.gz" -type f -mtime +7 -delete
# Clean up temp directory
rm -rf /tmp/$$BACKUP_NAME
echo "Backup completed at $$(date)"
sleep 86400 # Run once per day
done
'
OPTIONAL: if using an HP printer/scanner, un-comment the next section
Uses: https://github.com/manuc66/node-hp-scan-to
paperless-hp-scan:
image: docker.io/manuc66/node-hp-scan-to:latest
restart: unless-stopped
hostname: node-hp-scan-to
environment:
# REQUIRED - Change the next line to the IP address of your HP printer/scanner:
- IP=192.168.1.x
# Set the timezone to that of the host system:
- TZ="UTC"
# Set the created filename pattern:
- PATTERN="scan"_dd-mm-yyyy_hh-MM-ss
# Run the Docker container as the same user ID as the host system:
- PGID=1000
- PUID=1000
# Uncomment the next line to enable autoscanning a document when loaded into the scanner:
#- MAIN_COMMAND=adf-autoscan --pdf
volumes:
- ./consume:/scan
```