# Post\_app\_upgrade hook to keep custom paperless-ngx configuration

**URL:** https://forum.yunohost.org/t/post-app-upgrade-hook-to-keep-custom-paperless-ngx-configuration/41691
**Category:** Support apps
**Tags:** webhook, upgrade, paperless-ngx, english
**Created:** [February 26, 2026, 4:54pm UTC](https://forum.yunohost.org/t/post-app-upgrade-hook-to-keep-custom-paperless-ngx-configuration/41691 "2026-02-26T16:54:43Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![dazu](https://forum.yunohost.org/letter_avatar_proxy/v4/letter/d/b5a626/32.png) [@dazu](https://forum.yunohost.org/u/dazu)
#### Post date: [February 26, 2026, 4:54pm UTC](https://forum.yunohost.org/t/post-app-upgrade-hook-to-keep-custom-paperless-ngx-configuration/41691/1 "2026-02-26T16:54:43Z")

</div>

**What app is this about, and its version** : 2.20.8~ynh1  
**What YunoHost version are you running** : 12.1.39  
**What type of hardware are you using** : Virtual machine

### Describe your issue

I recently upgraded paperless-ngx, and again, saw my modifications to the file `/var/www/paperless-ngx/paperless.conf` to circumvent a longstanding bug ([OSError: image file is truncated (X bytes not processed)](https://github.com/paperless-ngx/paperless-ngx/discussions/11467)) overwritten 😕  
To my pleasant surprise, I discovered the hook system ([docs](https://doc.yunohost.org/en/dev/packaging/scripts/helpers_v2.0/)). However, initial experiments did not turn out as expected, so I wondered:  
(1) How you test a hook without rerunning the whole update? Just by setting the environment variables and executing the script?  
(2) How a more experienced user might go about adding the modifications to paperless.conf, instead of using `ynh_write_var_in_file`.  
(3) Comments on my (failing) attempt to hook into the process after the upgrade:

```auto
#!/bin/bash

source /usr/share/yunohost/helpers
app=$YNH_APP_INSTANCE_NAME

if [["$app" == "paperless-ngx"]]; then
   chmod 640 /var/www/paperless-ngx/paperless.conf  
ynh_write_var_in_file --file=/var/www/paperless-ngx/paperless.conf --key=PAPERLESS_OCR_USE>
  ynh_write_var_in_file --file=/var/www/paperless-ngx/paperless.conf --key=PILLOW_LOAD_TRU>
  chmod 400 /var/www/paperless-ngx/paperless.conf
  yunohost service reload_or_restart paperless-ngx paperless-ngx-consumer paperless-ngx-sc>
fi

```

### Share relevant logs or error messages

```auto
/etc/yunohost/hooks.d/post_app_upgrade# ./10-paperless-ngx 
+ return 1
+ ynh_write_var_in_file --file=/var/www/paperless-ngx/paperless.conf --key=PILLOW_LOAD_TRUNCATED_IMAGES --value=1 --after=PAPERLESS_OCR_USER_ARGS
+ local legacy_args=fkva
+ args_array=(['f']='file=' ['k']='key=' ['v']='value=' ['a']='after=')
+ local -A args_array
+ local file
+ local key
+ local value
+ local after
+ ynh_handle_getopts_args --file=/var/www/paperless-ngx/paperless.conf --key=PILLOW_LOAD_TRUNCATED_IMAGES --value=1 --after=PAPERLESS_OCR_USER_ARGS
++ set +o
++ grep xtrace
+ local 'xtrace_enable=set -o xtrace'
+ set +o xtrace
+ after=PAPERLESS_OCR_USER_ARGS
+ [[-f /var/www/paperless-ngx/paperless.conf]]
+ set +o xtrace
+ return 1
+ chmod 400 /var/www/paperless-ngx/paperless.conf
+ yunohost service reload_or_restart paperless-ngx paperless-ngx-consumer paperless-ngx-scheduler paperless-ngx-task-queue

```

---

<div class="post-metadata">

### Author: ![system](https://forum.yunohost.org/uploads/default/original/2X/f/f59fe8e3ee6b100b4f574d30d6e30479c68b89f0.png) [@system](https://forum.yunohost.org/u/system)
#### Post date: [March 13, 2026, 4:55pm UTC](https://forum.yunohost.org/t/post-app-upgrade-hook-to-keep-custom-paperless-ngx-configuration/41691/2 "2026-03-13T16:55:13Z")

</div>

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.
