Paperless-NGX Update (lohnt sich, Paperless-NGX wird schneller!!)

Nachdem das Backup nun die notwendige Sicherheit gibt um einen Update von Paperless-NGX durchzuführen gehen wir das doch mal an. Zu erst einmal ist sicherlich sinnvoll alle Paperless-NGX Services zu stoppen, damit nicht während des Updates Veränderung an den Daten durchgeführt werden.

user@2204lts:/opt$ sudo systemctl stop paperless-webserver.service
user@2204lts:/opt$ sudo systemctl stop paperless-scheduler.service
user@2204lts:/opt$ sudo systemctl stop paperless-consumer.service

Dann lege ich mal unter /opt ein /opt/temp an, in welches ich die aktuelle Software herunter lade und auspacke.

user@2204lts:/opt$ sudo mkdir /opt/temp
user@2204lts:/opt$ cd /opt/temp/
user@2204lts:/opt/temp$ sudo wget https://github.com/paperless-ngx/paperless-ngx/releases/download/v1.9.2/paperless-ngx-v1.9.2.tar.xz
--2022-10-16 14:07:47--  https://github.com/paperless-ngx/paperless-ngx/releases/download/v1.9.2/paperless-ngx-v1.9.2.tar.xz
Resolving github.com (github.com)... 140.82.121.4
<snip>
Length: 18636512 (18M) [application/octet-stream]
Saving to: ‘paperless-ngx-v1.9.2.tar.xz’

paperless-ngx-v1.9.2.tar.xz             100%[==============================================================================>]  17,77M  28,7MB/s    in 0,6s    

2022-10-16 14:07:48 (28,7 MB/s) - ‘paperless-ngx-v1.9.2.tar.xz’ saved [18636512/18636512]

user@2204lts:/opt/temp$ ls -la
-rw-r--r-- 1 root root 18636512 Sep 27 17:01 paperless-ngx-v1.9.2.tar.xz

Herunter geladen ist es, dann wollen wir es mal auspacken und uns ansehen, was alles dabei ist.

user@2204lts:/opt/temp$ sudo mkdir 1.9.2
user@2204lts:/opt/temp$ sudo tar -xvf paperless-ngx-v1.9.2.tar.xz -C 1.9.2/
<snip>
paperless-ngx/src/paperless_tesseract/tests/test_checks.py
paperless-ngx/src/paperless_tesseract/tests/__init__.py

user@2204lts:/opt/temp$ sudo ls -la 1.9.2/
drwxr-xr-x 7 1001 docker 4096 Sep 27 17:00 paperless-ngx
user@2204lts:/opt/temp$ 

Als erstes interessiert mich ein Vergleich von bestehender Paperless-NGX Konfig und der neuen Konfig.

user@2204lts:/opt/temp/1.9.2/paperless-ngx$ diff paperless.conf /opt/paperless-ngx/paperless.conf | more
6c6
< #PAPERLESS_DEBUG=false
---
> PAPERLESS_DEBUG=false
9,10c9
< 
< #PAPERLESS_REDIS=redis://localhost:6379
---
> PAPERLESS_REDIS=redis://localhost:6379
13,15c12,14
< #PAPERLESS_DBNAME=paperless
< #PAPERLESS_DBUSER=paperless
< #PAPERLESS_DBPASS=paperless
---
> #PAPERLESS_DBNAME="paperlessngx"
> #PAPERLESS_DBUSER="paperlessngx"
> #PAPERLESS_DBPASS="ganz geheim"
19,24c18,22
< 
< #PAPERLESS_CONSUMPTION_DIR=../consume
< #PAPERLESS_DATA_DIR=../data
< #PAPERLESS_TRASH_DIR=
< #PAPERLESS_MEDIA_ROOT=../media
< #PAPERLESS_STATICDIR=../static
---
> PAPERLESS_CONSUMPTION_DIR=/opt/paperless/consumption
> PAPERLESS_DATA_DIR=/opt/paperless/data
> PAPERLESS_TRASH_DIR=/opt/paperless/trash
> PAPERLESS_MEDIA_ROOT=/opt/paperless/media-root
> PAPERLESS_STATICDIR=/opt/paperless-ngx/static
26d23
< #PAPERLESS_FILENAME_FORMAT_REMOVE_NONE=
29,30c26
< 
< #PAPERLESS_SECRET_KEY=change-me
---
> PAPERLESS_SECRET_KEY=ganz_super_streng_geheim
42,46c38,41
< 
< #PAPERLESS_OCR_LANGUAGE=eng
< #PAPERLESS_OCR_MODE=skip
< #PAPERLESS_OCR_OUTPUT_TYPE=pdfa
< #PAPERLESS_OCR_PAGES=1
---
> PAPERLESS_OCR_LANGUAGE=deu+eng
> PAPERLESS_OCR_MODE=skip
> PAPERLESS_OCR_OUTPUT_TYPE=pdfa
> PAPERLESS_OCR_PAGES=0
48,51c43,46
< #PAPERLESS_OCR_CLEAN=clean
< #PAPERLESS_OCR_DESKEW=true
< #PAPERLESS_OCR_ROTATE_PAGES=true
< #PAPERLESS_OCR_ROTATE_PAGES_THRESHOLD=12.0
---
> PAPERLESS_OCR_CLEAN=clean
> PAPERLESS_OCR_DESKEW=true
> PAPERLESS_OCR_ROTATE_PAGES=true
> PAPERLESS_OCR_ROTATE_PAGES_THRESHOLD=12.0
53,54c48,49
< #PAPERLESS_CONVERT_MEMORY_LIMIT=0
< #PAPERLESS_CONVERT_TMPDIR=/var/tmp/paperless
---
> PAPERLESS_CONVERT_MEMORY_LIMIT=512000000
> PAPERLESS_CONVERT_TMPDIR=/var/tmp
57,60c52,54
< 
< #PAPERLESS_TASK_WORKERS=1
< #PAPERLESS_THREADS_PER_WORKER=1
< #PAPERLESS_TIME_ZONE=UTC
---
> PAPERLESS_TASK_WORKERS=2
> PAPERLESS_THREADS_PER_WORKER=2
> PAPERLESS_TIME_ZONE=Europe/Berlin
62,67c56,62
< #PAPERLESS_CONSUMER_DELETE_DUPLICATES=false
< #PAPERLESS_CONSUMER_RECURSIVE=false
< #PAPERLESS_CONSUMER_IGNORE_PATTERNS=[".DS_STORE/*", "._*", ".stfolder/*", ".stversions/*", ".localized/*", "desktop.ini"]
< #PAPERLESS_CONSUMER_SUBDIRS_AS_TAGS=false
< #PAPERLESS_CONSUMER_ENABLE_BARCODES=false
< #PAPERLESS_CONSUMER_BARCODE_STRING=PATCHT
---
> PAPERLESS_CONSUMER_DELETE_DUPLICATES=false
> PAPERLESS_CONSUMER_RECURSIVE=false
> PAPERLESS_CONSUMER_IGNORE_PATTERNS=[".DS_STORE/*", "._*", ".stfolder/*", ".stversions/*", ".localized/*", "desktop.ini"]
> PAPERLESS_CONSUMER_SUBDIRS_AS_TAGS=false
> PAPERLESS_CONSUMER_ENABLE_BARCODES=false
> PAPERLESS_CONSUMER_ENABLE_BARCODES=PATCHT
> PAPERLESS_OPTIMIZE_THUMBNAILS=true
70c65
< #PAPERLESS_FILENAME_DATE_ORDER=YMD
---
> PAPERLESS_FILENAME_DATE_ORDER=YMD
72d66
< #PAPERLESS_NUMBER_OF_SUGGESTED_DATES=5
78,81c72,74
< 
< #PAPERLESS_TIKA_ENABLED=false
< #PAPERLESS_TIKA_ENDPOINT=http://localhost:9998
< #PAPERLESS_TIKA_GOTENBERG_ENDPOINT=http://localhost:3000
---
> PAPERLESS_TIKA_ENABLED=true
> PAPERLESS_TIKA_ENDPOINT=http://localhost:9998
> PAPERLESS_TIKA_GOTENBERG_ENDPOINT=http://localhost:3000
84,86c77,79
< 
< #PAPERLESS_CONVERT_BINARY=/usr/bin/convert
< #PAPERLESS_GS_BINARY=/usr/bin/gs
---
> PAPERLESS_CONVERT_BINARY=/usr/bin/convert
> PAPERLESS_GS_BINARY=/usr/bin/gs
> PAPERLESS_OPTIPNG_BINARY=/usr/bin/optipng

Augenscheinlich sind keinen neuen oder geänderte Keys in die Konfig gekommen. Das beruhigt meine Aufregung vor einem Update doch erheblich. Na dann werden wir mal die neue Perperless.conf umbennen, damit unsere funktionierende Konfig nicht eine aufs Dach bekommt und in diesem Rutsch auch gleich die Dateien user User:paperless Group:paperless ändern.

Werfen wir noch einen Blick mit diff auf ein ggf. existierendes Delta bei folgenden Dateien:

  • gunicorn.conf.py
  • scripts/paperless-consumer.service
  • scripts/paperless-scheduler.service
  • scripts/paperless-webserver.service
gunicorn.conf.py
--------------->

user@2204lts:/opt/temp/1.9.2/paperless-ngx$ diff gunicorn.conf.py /opt/paperless-ngx/gunicorn.conf.py 
3,8c3,4
< # See https://docs.gunicorn.org/en/stable/settings.html for
< # explanations of settings
< 
< bind = f'{os.getenv("PAPERLESS_BIND_ADDR", "[::]")}:{os.getenv("PAPERLESS_PORT", 8000)}'
< 
< workers = int(os.getenv("PAPERLESS_WEBSERVER_WORKERS", 1))
---
> bind = f'0.0.0.0:{os.getenv("PAPERLESS_PORT", 8000)}'
> workers = int(os.getenv("PAPERLESS_WEBSERVER_WORKERS", 2))
11,14d6
< preload_app = True
< 
< # https://docs.gunicorn.org/en/stable/faq.html#blocking-os-fchmod
< worker_tmp_dir = "/dev/shm"
35c27
<     id2name = {th.ident: th.name for th in threading.enumerate()}
---
>     id2name = dict([(th.ident, th.name) for th in threading.enumerate()])
paperless-webserver.service
-------------------------->

user@2204lts:/opt/temp/1.9.2/paperless-ngx$ diff scripts/paperless-webserver.service /etc/systemd/system/paperless-webserver.service
11,12c11,12
< WorkingDirectory=/opt/paperless/src
< ExecStart=/opt/paperless/.local/bin/gunicorn -c /opt/paperless/gunicorn.conf.py paperless.asgi:application
---
> WorkingDirectory=/opt/paperless-ngx/src
> ExecStart=/opt/paperless/.local/bin/gunicorn -c /opt/paperless-ngx/gunicorn.conf.py paperless.asgi:application

paperless-scheduler.service
-------------------------->

user@2204lts:/opt/temp/1.9.2/paperless-ngx$ diff scripts/paperless-scheduler.service /etc/systemd/system/paperless-scheduler.service 
8c8
< WorkingDirectory=/opt/paperless/src
---
> WorkingDirectory=/opt/paperless-ngx/src

Hier kann ich auch keine wesentlichen Änerungen erkennen, welche einen Betrieb von Paperless-NGX verhindern würden.

Na dann bennen wir mal die neue paperless.conf und gunicorn.conf.py um. Ich hänge hier immer gerne einfach die neue Versionsnummer hinten dran.

user@2204lts:/opt/temp/1.9.2/paperless-ngx$ sudo mv gunicorn.conf.py gunicorn.conf.py.1.9.2
user@2204lts:/opt/temp/1.9.2/paperless-ngx$ sudo mv paperless.conf paperless.conf.1.9.2

user@2204lts:/opt/temp/1.9.2/paperless-ngx$ ls -la
-rw-r--r-- 1 1001 docker   1349 Sep 27 17:00 gunicorn.conf.py.1.9.2
-rw-r--r-- 1 1001 docker   2597 Sep 27 17:00 paperless.conf.1.9.2

Jetzt kommt der eigentliche Update. Ich überschreibe dabei alles in dem laufenden Verzeichnis. Da mv sich bei nicht leeren Verzeichnis quer stellt und ich die sowieso updaten möchte, lösche ich diese einfach vorher. Das sind bei diesem Update die Verzeichnisse ../docker, ../docs, ../scripts, ../src und ../static. und die Files .dockerignore und .env.

user@2204lts:/opt/paperless-ngx$ sudo rm -rf /opt/paperless-ngx/docker
user@2204lts:/opt/paperless-ngx$ sudo rm -rf /opt/paperless-ngx/docs
user@2204lts:/opt/paperless-ngx$ sudo rm -rf /opt/paperless-ngx/scripts
user@2204lts:/opt/paperless-ngx$ sudo rm -rf /opt/paperless-ngx/src
user@2204lts:/opt/paperless-ngx$ sudo rm -rf /opt/paperless-ngx/static
user@2204lts:/opt/paperless-ngx$ sudo rm -rf /opt/paperless-ngx/.env
user@2204lts:/opt/paperless-ngx$ sudo rm -rf /opt/paperless-ngx/.dockerignore


user@2204lts:/opt/paperless-ngx$ sudo mv -viu /opt/temp/1.9.2/paperless-ngx/* /opt/paperless-ngx/
renamed '/opt/temp/1.9.2/paperless-ngx/docker' -> '/opt/paperless-ngx/docker'
renamed '/opt/temp/1.9.2/paperless-ngx/docs' -> '/opt/paperless-ngx/docs'
renamed '/opt/temp/1.9.2/paperless-ngx/scripts' -> '/opt/paperless-ngx/scripts'
renamed '/opt/temp/1.9.2/paperless-ngx/src' -> '/opt/paperless-ngx/src'
renamed '/opt/temp/1.9.2/paperless-ngx/static' -> '/opt/paperless-ngx/static'


user@2204lts:/opt/paperless-ngx$ sudo chown paperless:paperless -Rfv /opt/paperless-ngx/*

user@2204lts:/opt/paperless-ngx$ ls -la
total 272
drwxr-xr-x 8      1001 paperless   4096 Okt 16 14:59 .
drwxrwxrwx 8 root      root        4096 Okt 16 14:07 ..
drwxr-xr-x 3 paperless paperless   4096 Apr 25 18:57 data
drwxr-xr-x 3 paperless paperless   4096 Okt 16 14:51 docker
-rw-r--r-- 1 paperless paperless   7919 Sep 27 17:00 Dockerfile
drwxr-xr-x 5 paperless paperless   4096 Sep 27 17:00 docs
-rw-r--r-- 1 paperless paperless   1119 Apr 25 18:57 gunicorn.conf.py
-rw-r--r-- 1 paperless paperless   1349 Sep 27 17:00 gunicorn.conf.py.1.9.2
-rw-r--r-- 1 paperless paperless  35142 Sep 27 17:00 LICENSE
-rw-r--r-- 1 paperless paperless   2742 Sep 19 18:35 paperless.conf
-rw-r--r-- 1 paperless paperless   2597 Sep 27 17:00 paperless.conf.1.9.2
-rw-r--r-- 1 paperless paperless   2743 Sep 19 18:31 paperless.conf.bak
-rw-r--r-- 1 paperless paperless   2598 Mai  8 09:08 paperless.conf.org
-rw-r--r-- 1 paperless paperless   1860 Sep 27 17:00 Pipfile
-rw-r--r-- 1 paperless paperless 155459 Sep 27 17:00 Pipfile.lock
-rw-r--r-- 1 paperless paperless   8812 Sep 27 17:00 README.md
-rw-r--r-- 1 paperless paperless   3918 Sep 27 17:00 requirements.txt
drwxr-xr-x 2 paperless paperless   4096 Sep 27 17:00 scripts
drwxr-xr-x 9 paperless paperless   4096 Sep 27 17:00 src
drwxr-xr-x 7 paperless paperless   4096 Sep 27 17:00 static

Damit sind die Files da, wo sie liegen sollen. Als nächstes sind die neuen Requierments zu installieren.

user@2204lts:/opt/paperless-ngx$ cd /opt/paperless-ngx/
user@2204lts:/opt/paperless-ngx$ sudo -Hu paperless pip3 install -r requirements.txt
<snip>

user@2204lts:/opt/paperless-ngx$ cd src/
user@2204lts:/opt/paperless-ngx/src$ sudo -Hu paperless python3 manage.py migrate
Operations to perform:
  Apply all migrations: admin, auth, authtoken, contenttypes, django_q, documents, paperless_mail, sessions
Running migrations:
  Applying documents.1019_uisettings... OK
  Applying documents.1019_storagepath_document_storage_path... OK
  Applying documents.1020_merge_20220518_1839... OK
  Applying documents.1021_webp_thumbnail_conversion...[2022-10-16 17:15:52,689] [INFO] [paperless.migrations] 
<snip>
[2022-10-16 17:15:53,375] [INFO] [paperless.migrations] Conversion to WebP completed, replaced 0000595.png with 0000595.webp
[2022-10-16 17:15:53,395] [INFO] [paperless.migrations] Conversion to WebP completed, replaced 0000583.png with 0000583.webp
[2022-10-16 17:15:53,400] [INFO] [paperless.migrations] Conversion completed in 0.717s
 OK
  Applying documents.1022_paperlesstask... OK
  Applying documents.1023_add_comments... OK
  Applying documents.1024_document_original_filename... OK
  Applying documents.1025_alter_savedviewfilterrule_rule_type... OK
  Applying paperless_mail.0015_alter_mailrule_action... OK

Das scheint alles sauber gelaufen zu sein. Dann gebe ich dem Server mal eine auf die Nuss und gucke, ob die Website wieder da ist.

user@2204lts:/opt/paperless-ngx/src$ sudo reboot
Connection to 192.168.2.158 closed by remote host.
Connection to 192.168.2.158 closed.

Und nach dem Reload… trommel wirbel…

Der Webserver ist da und ganz klein unten links in der Ecke steht die Version v1.9.2. Das sieht nach einem gültigen Versuch aus und ein kleiner Test, ob er auch wieder Dokumente an nimmt –> läuft.

Paperless-NGX v.1.9.2

Das könnte dich auch interessieren …

Eine Antwort

  1. Florian sagt:

    Ich nutze Paperless NGX sehr sinnvoll zusammen mit einem alten Brother Scanner, den ich dank Linux Support von Brother in den Paperless Workflow super einbinden konnte. Meine Konfiguration habe ich hier beschrieben: https://technikauswahl.de/2023/02/brother-hardware-tasten-sinnvoll-fuer-paperless-ngx-nutzen/

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert