Skip to content

Commit 7be643e

Browse files
committed
Fix backup path check and default value
1 parent 4878242 commit 7be643e

File tree

4 files changed

+26
-16
lines changed

4 files changed

+26
-16
lines changed

paperless-ngx/DOCS.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ ssl: false
7171
certfile: fullchain.pem
7272
keyfile: privkey.pem
7373
backup_enabled: false
74-
backup_path: /share/paperless/exports
74+
backup_path: /data/exports
7575
backup_cron: "0 3 * * *"
7676
backup_keep_count: 3
7777
```
@@ -162,11 +162,11 @@ Enables or disables automatic backups of your Paperless data. Set to `true` to e
162162

163163
### Option: `backup_path`
164164

165-
Specifies the directory where backup files will be stored. The default path is `/share/paperless/exports`.
165+
Specifies the directory where backup files will be stored. The default path is `/data/exports`.
166166

167167
### Option: `backup_cron`
168168

169-
Defines the cron schedule for automatic backups. The default value `"0 3 * * *"` runs backups daily at 3:00 AM. Use standard cron syntax to customize the backup schedule.
169+
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.
170170

171171
### Option: `backup_keep_count`
172172

paperless-ngx/config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ options:
3838
ingress_auth: false
3939
tika_gotenberg: false
4040
backup_enabled: false
41-
backup_path: /share/paperless/exports
41+
backup_path: "/data/exports"
4242
backup_cron: "0 3 * * *"
4343
backup_keep_count: 3
4444
schema:
@@ -63,7 +63,7 @@ schema:
6363
ingress_auth: bool
6464
tika_gotenberg: bool
6565
locales: str?
66-
backup_enabled: bool
67-
backup_path: str
68-
backup_cron: str
66+
backup_enabled: bool
67+
backup_path: str
68+
backup_cron: str
6969
backup_keep_count: int

paperless-ngx/rootfs/etc/cont-init.d/90-cron-backup.sh

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@ set -e
44

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

7-
if type bashio >/dev/null 2>&1; then
8-
CRON_SCHEDULE="$(bashio::config 'backup_cron')"
7+
if bashio::config.has_value 'backup_enabled'; then
98
BACKUP_ENABLED="$(bashio::config 'backup_enabled')"
10-
BACKUP_KEEP_COUNT="$(bashio::config 'backup_keep_count')"
119
else
12-
CRON_SCHEDULE="0 2 * * *"
1310
BACKUP_ENABLED="false"
14-
BACKUP_KEEP_COUNT=-1
11+
fi
12+
13+
if bashio::config.has_value 'backup_cron'; then
14+
CRON_SCHEDULE="$(bashio::config 'backup_cron')"
15+
else
16+
CRON_SCHEDULE="0 2 * * *"
1517
fi
1618

1719
if [ "$BACKUP_ENABLED" == "false" ]; then
@@ -25,4 +27,4 @@ echo "${CRON_SCHEDULE} /usr/local/bin/paperless_backup.sh" > /etc/cron.d/paperle
2527

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

28-
echo "[INFO] Backup cron job configured with schedule: $CRON_SCHEDULE & keep_count: $BACKUP_KEEP_COUNT"
30+
echo "[INFO] Backup cron job configured with schedule: $CRON_SCHEDULE"

paperless-ngx/rootfs/usr/local/bin/paperless_backup.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,25 @@
22
# shellcheck shell=bash
33
set -e
44

5-
if type bashio >/dev/null 2>&1; then
6-
BACKUP_KEEP_COUNT="$(bashio::config 'backup_keep_count')"
5+
if bashio::config.has_value 'backup_path'; then
76
BACKUP_PATH="$(bashio::config 'backup_path')"
87
else
8+
echo "[ERROR] No backup path configured. Please set 'backup_path' in the add-on configuration."
9+
exit 1
10+
fi
11+
12+
if bashio::config.has_value 'backup_keep_count'; then
13+
BACKUP_KEEP_COUNT="$(bashio::config 'backup_keep_count')"
14+
else
15+
echo "[WARN] 'backup_keep_count' not set, defaulting to 3"
916
BACKUP_KEEP_COUNT=3
10-
BACKUP_PATH="/share/paperless/exports"
1117
fi
1218

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

22+
mkdir -p "$BACKUP_PATH"
23+
1624
python3 manage.py document_exporter \
1725
"$BACKUP_PATH" \
1826
-z \

0 commit comments

Comments
 (0)