Skip to content

Commit c6a8016

Browse files
feat: add README for helm-paperless-s3-backup chart and update configuration options
1 parent 31bab96 commit c6a8016

File tree

4 files changed

+99
-15
lines changed

4 files changed

+99
-15
lines changed

README.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Helm Chart: Paperless S3 Backup
2+
3+
This Helm chart deploys a CronJob to back up Paperless NGX documents to an S3-compatible storage with optional sse -c encryption.
4+
5+
## Installation
6+
7+
To install with custom values:
8+
9+
```bash
10+
helm install paperless-backup ./helm-paperless-s3-backup -f values.yaml -n <NAMESPACE>
11+
```
12+
13+
## Configuration
14+
15+
### Values
16+
17+
| Key | Default Value | Description |
18+
|--------------------|---------------------|-------------|
19+
| `cron` | `"0 4 * * 0"` | Cron schedule for backups (UTC) |
20+
| `image.repository` | `pascaaal/docker-awscli-gpg` | Backup container image repository |
21+
| `image.tag` | `v1.0.7` | Container image tag |
22+
| `s3.accessKey` | `""` | S3 Access Key ID |
23+
| `s3.secretKey` | `""` | S3 Secret Access Key |
24+
| `s3.bucket` | `""` | Target S3 bucket name |
25+
| `s3.endpoint` | `""` | S3 endpoint including `https://` |
26+
| `s3.region` | `""` | S3 region |
27+
| `s3.sseKey` | `""` | 32-byte hex key for server-side encryption (SSE-C) |
28+
| `paperless.namespace` | `""` | Namespace of Paperless deployment |
29+
| `paperless.app` | `""` | Label of the Paperless pod |
30+
| `paperless.container_name` | `""` | Paperless container name |
31+
32+
## Example `values.yaml`
33+
34+
```yaml
35+
cron: "0 3 * * *"
36+
37+
image:
38+
repository: pascaaal/docker-awscli-gpg
39+
tag: v1.0.7
40+
41+
s3:
42+
accessKey: "your-access-key"
43+
secretKey: "your-secret-key"
44+
bucket: "your-backup-bucket"
45+
endpoint: "https://s3.example.com"
46+
region: "us-east-1"
47+
sseKey: "your-32-byte-hex-key" # encryption is enabled, when key is set
48+
49+
paperless:
50+
namespace: "paperless"
51+
app: "paperless"
52+
container_name: "paperless-container"
53+
```
54+
55+
## Generate encryption key
56+
```bash
57+
openssl rand -hex 32
58+
```
59+
60+
## Decrypt backup
61+
```bash
62+
export S3_SSE_KEY=154cd74642087d8d8d36c9136b89fb10b42a745c12108092895de44ed03518c0
63+
echo $S3_SSE_KEY | xxd -r -p > .sse-c.key
64+
aws s3 sync s3://<BUCKET_NAME> . --endpoint-url https://<ENDPOINT_URL> --sse-c AES256 --sse-c-key fileb://.sse-c.key
65+
```
66+
67+
## View logs
68+
```bash
69+
kubectl logs -l app=paperless-backup -n <NAMESPACE> -c paperless-backup
70+
```
71+
## Uninstallation
72+
73+
To remove the deployment:
74+
75+
```bash
76+
helm uninstall paperless-backup
77+
```
78+
79+
## Notes
80+
- Ensure that the S3 credentials have appropriate permissions to write to the bucket.
81+
- Treat your encryption key like your car keys—lose it, and you’re not going anywhere… especially not to your backups! 🚗🔑
82+
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
apiVersion: v2
22
name: helm-paperless-s3-backup
3-
description: A Helm chart for Kubernetes
3+
description: A Helm chart for automating Paperless NGX backups to a S3 bucket in Kubernetes with optional encryption.
44
type: application
5-
version: 0.1.1
6-
appVersion: "1.16.0"
5+
version: 0.2.0
6+
appVersion: "1.0.7"

charts/helm-paperless-s3-backup/templates/configmap.yaml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ data:
1818
error() { log "ERROR" "$1"; }
1919
2020
# Validate environment variables
21-
: "${S3_SSE_KEY:?$(error 'Environment variable S3_SSE_KEY not set')}"
2221
: "${S3_BUCKET:?$(error 'Environment variable S3_BUCKET not set')}"
2322
: "${S3_ENDPOINT:?$(error 'Environment variable S3_ENDPOINT not set')}"
2423
: "${S3_REGION:?$(error 'Environment variable S3_REGION not set')}"
@@ -30,9 +29,11 @@ data:
3029
TIMESTAMP=$(date +%Y-%m-%d_%H-%M-%S)
3130
FILE_NAME="paperless-backup-$TIMESTAMP"
3231
33-
# Import the key
34-
S3_SSE_C_PATH="/mnt/backup/.sse-c.key"
35-
echo $S3_SSE_KEY | xxd -r -p > $S3_SSE_C_PATH
32+
# Import the key if S3_SSE_KEY is set
33+
if [ -n "$S3_SSE_KEY" ]; then
34+
S3_SSE_C_PATH="/mnt/backup/.sse-c.key"
35+
echo "$S3_SSE_KEY" | xxd -r -p > "$S3_SSE_C_PATH"
36+
fi
3637
3738
info "Creating backup with document exporter..."
3839
kubectl exec ${PAPERLESS_POD} --container $PAPERLESS_CONTAINER_NAME -- \
@@ -52,13 +53,14 @@ data:
5253
7z x /mnt/backup/paperless-backup-*.zip -o/mnt/backup/export/
5354
5455
info "Uploading backup to S3..."
55-
aws s3 sync \
56-
/mnt/backup/export \
57-
s3://$S3_BUCKET \
58-
--endpoint-url $S3_ENDPOINT \
59-
--region $S3_REGION \
60-
--sse-c AES256 \
61-
--sse-c-key fileb://$S3_SSE_C_PATH
56+
CMD="aws s3 sync /mnt/backup/export s3://$S3_BUCKET --endpoint-url $S3_ENDPOINT --region $S3_REGION"
57+
58+
if [ -n "$S3_SSE_KEY" ]; then
59+
CMD="$CMD --sse-c AES256 --sse-c-key fileb://$S3_SSE_C_PATH"
60+
info "Using server-side encryption with customer-provided key"
61+
fi
62+
63+
eval "$CMD"
6264
6365
info "Cleaning up backup file..."
6466
kubectl exec ${PAPERLESS_POD} --container ${PAPERLESS_CONTAINER_NAME} -- \

charts/helm-paperless-s3-backup/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ s3:
1212
bucket: ""
1313
endpoint: "" # including https://
1414
region: ""
15-
sseKey: "" # 32 bytes hex key (openssl rand -hex 32) for server-side encryption
15+
sseKey: "" # 32 bytes hex key (openssl rand -hex 32) for server-side encryption (encprytion enabled when set)
1616

1717
paperless:
1818
namespace: ""

0 commit comments

Comments
 (0)