[sharing my project] Paperless-ngx to Nextcloud synchronization via WebDAV

Hi all,

I want to share a solution I created to set up a connection between Paperless-ngx and Nextcloud. Since my wife doesn’t want to look in different services to find a single document, she asked me if we also can have the Paperless data available in Nextcloud. I said sure but then figured out, that none of the solutions around fulfill our requirements:

  • Easy and quick configuration.
  • Synchronization with remote Nextcloud instances.
  • Files created, deleted, or modified appear in Nextcloud’s Activity Feed.
  • PDFs can be fund using the search within Nextcloud.
  • Real-time synchronization.

(More details in the table below)

So, what I did is to set up a docker container which can easily be added to the existing Paperless stack/compose file and then connects to Nextcloud with the given WebDAV Address and credentials. It does initial bulk file loading and sets up a file watcher to synchronize changes in real-time. This makes the PDF searchable in Nextcloud and they appear in the activity-feed:

nextcloud-activity_example.png

The code is open source available and the container image is pre-built. So, feel free to use it and give me some feedback for improvements if you like.

And if you like my work i would be happy to get some donations:

And for the record, here’s a comparison between the data exchange options for Paperless and Nextcloud:

Nextcloud Paperless App Local Mount SFTP or SMB/CIFS š My Container
Easy SetUp :white_check_mark: :white_check_mark: :white_check_mark: :white_check_mark: ²
Paperless Files available in Nextcloud :cross_mark: :white_check_mark: :white_check_mark: :white_check_mark:
Send files to Paperless consume (File input) :white_check_mark: ³ :check_box_with_check: ⁴ :check_box_with_check: ⁴ :cross_mark: ³
Services on another Host (same Network) :white_check_mark: :cross_mark: :white_check_mark: :white_check_mark:
remote Services :white_check_mark: :cross_mark: :check_box_with_check: ⁾ :white_check_mark:
Files available in the Nextcloud Search :cross_mark: Âł :cross_mark: :cross_mark: :white_check_mark:
Recent Paperless-changes available in Nextcloud Activity App :cross_mark: Âł :cross_mark: :cross_mark: :white_check_mark:
Paperless Files backed up in Nextcloud :cross_mark: :cross_mark: :cross_mark: :white_check_mark: ⁜
Works with both: Docker and Bare Metal :white_check_mark: :white_check_mark: ⁡ :white_check_mark: ⁡ :multiply: ⁸

š Additional FTP or SMB/CIFS service required
² see prerequisites
Âł Nextcloud Paperless App: from Nextcloud to Paperless only / My container: from Paperless to Nextcloud only
⁴ a second external Mount with writing permission required
⁾ only SFTP (SMB/CIFS not recommended over the Internet!)
⁜ this does NOT replace a regular Backup including the Paperless Database
⁡ for Docker: ensure correct mounting
⁸ untested. Probably won’t work OOTB and requires a more complex set-up

4 Likes

Great job, and I am glad for sharing both the solution and the comparison! :clap:

I’ve recently dealt with a very similar setup using Nextcloud AIO (Hub 9) alongside a containerized Paperless-ngx installation.

In my case, I originally wanted the consume folder in Paperless to be directly used as a shared folder in Nextcloud, so I could upload documents via the Nextcloud client. Unfortunately, this turned out to be unreliable — the Paperless container kept overwriting ownership permissions (chown to the container’s UID/GID), which resulted in me being unable to add any files to that shared folder through Nextcloud (due to insufficient permissions).

In the end, I solved it by writing a simple cron script that:

  • checks the shared Nextcloud folder (e.g. Import-Paperless) every minute,
  • if it finds a new PDF, it automatically copies it to the consume folder,
  • before copying, it calculates a hash (e.g. SHA256) of the file and compares it against a log to avoid duplicate imports.

This allows me to upload documents easily via the Nextcloud web or desktop client, and at the same time, Paperless processes them safely without ownership conflicts or access issues.

If anyone’s interested, I can also share the structure of the script.

1 Like

Hi vawaver,
I’m glad you like it. I also had the issue you are describing and solved it via an additional proftp container. This is also described in an additional readme in my repository. This also enables me to directly scan to paperless with almost any network scanner:

and with the ftp-server in between all permission issues were resolved too :slight_smile:

1 Like