Multiple Paperless Instances

This nearly killed me, I thought I had nuked everything but in the end it was way easier and simpler than I had feared.

Assuming you used one of the default .yaml and .env files from the paperless-ngx github you first need to add a database. I use portainer so went to the db shell and then did this to log in, list them, create a new one, check it is there and quit:

psql -U paperless
\l
CREATE DATABASE mynewdb;
\l
\q
exit

Next I needed to make a new env file. I just Save As… with the existing one and called it docker-compose-mynewone.env and added these lines:

PAPERLESS_DBNAME=mynewdb
PAPERLESS_SECRET_KEY=an+all+new+random+set+of+characters
PAPERLESS_URL=https://mynewpapaerless.myfinedomain.com

The .yaml file needs one new section – I copied the webserver one and only changed these lines (the first instance is on 8010). The /1 on the end of the PAPERLESS_REDIS means use a second database and you need all new volumes or things go awry (I found this out the hard way).

  webserver-newone:
    ports:
      - "8011:8000"
    env_file: docker-compose-mynewone.env
    environment:
      PAPERLESS_REDIS: redis://broker:6379/1
    volumes:
      - data-new:/usr/src/paperless/data
      - media-new:/usr/src/paperless/media
      - ./export-new:/usr/src/paperless/export
      - ./consume-new:/usr/src/paperless/consume

You need to tweak the original webserver changing just this one line with the /0.

  webserver:
      PAPERLESS_REDIS: redis://broker:6379/0

Then yougo to the folder with the yaml in console, stop all the instances, pull a new one and create a superuser as per the usual, but with a minor difference (the new webserver name):

docker compose down
docker compose pull
docker compose run --rm webserver-newone createsuperuser
docker compose up -d

And that should be it!

Leave a Reply

Your email address will not be published. Required fields are marked *