Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.devcontainer/
.vscode/
20 changes: 20 additions & 0 deletions paperless-ngx/DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ consumer_subdirs_as_tags: false
ssl: false
certfile: fullchain.pem
keyfile: privkey.pem
backup_enabled: false
backup_path: /data/exports
backup_cron: "0 3 * * *"
backup_keep_count: 3
```

### Option: `url`
Expand Down Expand Up @@ -152,6 +156,22 @@ The private key file to use for SSL.

Let you set `client_max_body_size` of _nginx_ manually

### Option: `backup_enabled`

Enables or disables automatic backups of your Paperless data. Set to `true` to enable scheduled backups. `false` ist default.

### Option: `backup_path`

Specifies the directory where backup files will be stored. The default path is `/data/exports`.

### Option: `backup_cron`

Defines the cron schedule for automatic backups. The default value `"0 2 * * *"` runs backups daily at 3:00 AM. Use standard cron syntax to customize the backup schedule.

### Option: `backup_keep_count`

Sets the number of most recent backups to retain. Older backups beyond this count will be automatically deleted. The default is `3` backups.

### More personalisation

You can add more configurations options in `/addon_config/paperless_ngx/paperless.conf`
Expand Down
21 changes: 20 additions & 1 deletion paperless-ngx/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@
libgs10-common=${GHOSTSCRIPT_VERSION} \
ghostscript=${GHOSTSCRIPT_VERSION} \
libjbig2enc-dev=0.30-1 \
qpdf=12.2.0-1"
qpdf=12.2.0-1 \
zip \
unzip"

# Buildx provided, must be defined to use though
ARG TARGETARCH
Expand All @@ -109,7 +111,7 @@
# Install basic runtime packages.
# These change very infrequently
# hadolint ignore=DL3003,DL3042,DL3008,SC2086
RUN --mount=type=cache,target=/root/.cache/uv/,id=uv-cache \

Check failure on line 114 in paperless-ngx/Dockerfile

View workflow job for this annotation

GitHub Actions / workflows / Hadolint

DL3009 info: Delete the apt-get lists after installing something
set -eux \
echo "Installing system packages" \
&& apt-get update \
Expand Down Expand Up @@ -145,7 +147,7 @@

# Install requirements
# hadolint ignore=DL3042,DL3008,DL3013,SC2086
RUN --mount=type=cache,target=/root/.cache/uv/,id=uv-cache \

Check failure on line 150 in paperless-ngx/Dockerfile

View workflow job for this annotation

GitHub Actions / workflows / Hadolint

SC2035 info: Use ./*glob* or -- *glob* so names with dashes won't become options.
set -eux \
&& echo "Installing build system packages" \
&& apt-get update \
Expand All @@ -168,6 +170,19 @@
&& rm -rf /var/tmp/* \
&& rm -rf /var/cache/apt/archives/


# Install supercronic
# Latest releases available at https://github.com/aptible/supercronic/releases
ENV SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.2.41/supercronic-linux-amd64 \
SUPERCRONIC_SHA1SUM=f70ad28d0d739a96dc9e2087ae370c257e79b8d7 \
SUPERCRONIC=supercronic-linux-amd64

RUN curl -fsSLO "$SUPERCRONIC_URL" \
&& echo "${SUPERCRONIC_SHA1SUM} ${SUPERCRONIC}" | sha1sum -c - \
&& chmod +x "$SUPERCRONIC" \
&& mv "$SUPERCRONIC" "/usr/local/bin/${SUPERCRONIC}" \
&& ln -s "/usr/local/bin/${SUPERCRONIC}" /usr/local/bin/supercronic

WORKDIR /usr/src/paperless/docker/

RUN set -eux \
Expand Down Expand Up @@ -202,6 +217,10 @@
# Copy root filesystem
COPY rootfs/ /

RUN chmod +x /usr/local/bin/paperless_backup.sh \
&& chmod +x /etc/cont-init.d/90-cron-backup.sh \
&& chmod +x /etc/services.d/supercronic/run

# Build arguments
ARG BUILD_ARCH
ARG BUILD_DATE
Expand Down
8 changes: 8 additions & 0 deletions paperless-ngx/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ options:
keyfile: privkey.pem
ingress_auth: false
tika_gotenberg: false
backup_enabled: false
backup_path: "/data/exports"
backup_cron: "0 3 * * *"
backup_keep_count: 3
schema:
url: str?
csrf_allowed:
Expand All @@ -59,3 +63,7 @@ schema:
ingress_auth: bool
tika_gotenberg: bool
locales: str?
backup_enabled: bool
backup_path: str
backup_cron: str
backup_keep_count: int
30 changes: 30 additions & 0 deletions paperless-ngx/rootfs/etc/cont-init.d/90-cron-backup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/command/with-contenv bashio
# shellcheck shell=bash
set -e

echo "[INFO] Configuring backup cron job..."

if bashio::config.has_value 'backup_enabled'; then
BACKUP_ENABLED="$(bashio::config 'backup_enabled')"
else
BACKUP_ENABLED="false"
fi

if bashio::config.has_value 'backup_cron'; then
CRON_SCHEDULE="$(bashio::config 'backup_cron')"
else
CRON_SCHEDULE="0 2 * * *"
fi

if [ "$BACKUP_ENABLED" == "false" ]; then
echo "[INFO] Backup cron job is disabled in configuration. Skipping setup."
exit 0
fi

mkdir -p /etc/cron.d

echo "${CRON_SCHEDULE} /usr/local/bin/paperless_backup.sh >> /proc/1/fd/1 2>&1" > /etc/cron.d/paperless-backup

chmod 0644 /etc/cron.d/paperless-backup

echo "[INFO] Backup cron job configured with schedule: $CRON_SCHEDULE"
3 changes: 3 additions & 0 deletions paperless-ngx/rootfs/etc/services.d/supercronic/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/command/with-contenv bashio
# shellcheck shell=bash
exec /usr/local/bin/supercronic /etc/cron.d/paperless-backup
45 changes: 45 additions & 0 deletions paperless-ngx/rootfs/usr/local/bin/paperless_backup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/command/with-contenv bashio
# shellcheck shell=bash
set -e

cd /usr/src/paperless/src || { echo "[ERROR] Cannot change into /usr/src/paperless/src"; exit 1; }

if bashio::config.has_value 'backup_path'; then
BACKUP_PATH="$(bashio::config 'backup_path')"
else
echo "[ERROR] No backup path configured. Please set 'backup_path' in the add-on configuration."
exit 1
fi

if bashio::config.has_value 'backup_keep_count'; then
BACKUP_KEEP_COUNT="$(bashio::config 'backup_keep_count')"
else
echo "[WARN] 'backup_keep_count' not set, defaulting to 3"
BACKUP_KEEP_COUNT=3
fi

NOW=$(date '+%Y-%m-%d-%H:%M:%S')
echo "[INFO] Backup started: $NOW"

mkdir -p "$BACKUP_PATH"

python3 manage.py document_exporter \
"$BACKUP_PATH" \
-z \
-zn "paperless-export-$NOW" \
--no-progress-bar \
|| { echo "[ERROR] Creating export failed"; exit 1; }

echo "[INFO] Backup completed: $BACKUP_PATH/paperless-export-$NOW.zip"

# -----------------------------
# Delete old backups
# -----------------------------
mapfile -t BACKUPS < <(ls -1t "$BACKUP_PATH"/paperless-export-*.zip 2>/dev/null)

if [ "${#BACKUPS[@]}" -gt "$BACKUP_KEEP_COUNT" ]; then
for ((i=BACKUP_KEEP_COUNT; i<${#BACKUPS[@]}; i++)); do
echo "[INFO] Deleting old backup: ${BACKUPS[i]}"
rm -f "${BACKUPS[i]}"
done
fi
12 changes: 12 additions & 0 deletions paperless-ngx/translations/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,17 @@ configuration:
locales:
name: Locales
description: Your language (fr_FR, en_US, de_DE, etc)
backup_enabled:
name: Enable Backup
description: Enable or disable automatic backups
backup_path:
name: Backup Path
description: Path to store backups
backup_cron:
name: Backup Cron Schedule
description: Cron schedule for automatic backups
backup_keep_count:
name: Backup Keep Count
description: Number of backups to keep
network:
80/tcp: Web interface (Not required for Ingress)