Skip to content

Commit 6e3a737

Browse files
committed
docs: add flexible GPG key import from files, URLs and environment variables
1 parent a7694bb commit 6e3a737

File tree

4 files changed

+156
-6
lines changed

4 files changed

+156
-6
lines changed

docs/README.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ python3 imapbackup.py \
6767
4. **[Restore Guide](restore-guide.md)** - How to restore emails from backups
6868
5. **[S3 Configuration](s3-setup.md)** - Setting up S3 storage (MinIO, Hetzner, AWS)
6969
6. **[GPG Encryption Guide](gpg-setup.md)** - Encrypting your backups
70+
7. **[GPG Key Import Guide](gpg-key-import.md)** - Flexible GPG key import (files, URLs, environment variables)
7071

7172
## Common Use Cases
7273

@@ -80,9 +81,30 @@ Use cron to schedule daily backups:
8081
-s imap.example.com -u user@example.com -p @/root/.imap_password -e
8182
```
8283

83-
### Backup and Upload to S3 with Encryption
84+
### Backup and Upload to S3 with Encryption (Easy Method)
8485

8586
```bash
87+
# Using flexible key import - no GPG keyring mount needed
88+
docker run --rm \
89+
-v $(pwd)/backups:/data \
90+
user2k20/imapbackup \
91+
-s imap.example.com -u user@example.com -e \
92+
--s3-upload \
93+
--s3-endpoint=https://s3.eu-central-1.hetzner.cloud \
94+
--s3-bucket=email-backups \
95+
--s3-access-key=$S3_KEY \
96+
--s3-secret-key=$S3_SECRET \
97+
--gpg-encrypt \
98+
--gpg-recipient=backup@example.com \
99+
--gpg-import-key=https://example.com/keys/backup-public.asc
100+
```
101+
102+
See [GPG Key Import Guide](gpg-key-import.md) for more examples including environment variables and file paths.
103+
104+
### Backup and Upload to S3 with Encryption (Traditional Method)
105+
106+
```bash
107+
# Using mounted GPG keyring
86108
docker run --rm \
87109
-v $(pwd)/backups:/data \
88110
-v $(pwd)/.gnupg:/root/.gnupg \
@@ -149,6 +171,10 @@ docker run --rm \
149171

150172
- `--gpg-encrypt` - Enable GPG encryption/decryption
151173
- `--gpg-recipient=EMAIL` - GPG key ID or email
174+
- `--gpg-import-key=SOURCE` - Import GPG public key from:
175+
- File path: `/path/to/key.asc`
176+
- URL: `https://example.com/key.asc`
177+
- Environment variable: `env:GPG_PUBLIC_KEY`
152178

153179
## Requirements
154180

docs/backup-guide.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,37 @@ docker run --rm \
184184

185185
## Encrypted Backups
186186

187-
### Backup with GPG Encryption
187+
### Backup with GPG Encryption (Public Key Auto-Import)
188+
189+
**Recommended**: Use the flexible key import feature - no GPG keyring mount needed for encryption:
190+
191+
```bash
192+
docker run --rm \
193+
-v $(pwd)/backups:/data \
194+
user2k20/imapbackup \
195+
-s imap.example.com \
196+
-u user@example.com \
197+
-e \
198+
--s3-upload \
199+
--s3-endpoint=https://s3.hetzner.cloud \
200+
--s3-bucket=secure-backups \
201+
--s3-access-key=$S3_KEY \
202+
--s3-secret-key=$S3_SECRET \
203+
--gpg-encrypt \
204+
--gpg-recipient=backup@example.com \
205+
--gpg-import-key=https://example.com/keys/backup-public.asc
206+
```
207+
208+
The `--gpg-import-key` option supports:
209+
- **File paths**: `--gpg-import-key=/path/to/key.asc`
210+
- **URLs**: `--gpg-import-key=https://example.com/public-key.asc`
211+
- **Environment variables**: `--gpg-import-key=env:GPG_PUBLIC_KEY`
212+
213+
For complete examples and workflows, see [GPG Key Import Guide](gpg-key-import.md).
214+
215+
### Backup with GPG Encryption (Traditional Method)
216+
217+
If you prefer mounting your GPG keyring:
188218

189219
```bash
190220
docker run --rm \

docs/docker-setup.md

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,25 @@ Example:
4949

5050
### `/root/.gnupg` - GPG Keyring (Optional)
5151

52-
Required only if using GPG encryption:
52+
**Method 1**: Use the new `--gpg-import-key` option (no mount needed for encryption):
53+
54+
```bash
55+
# No GPG volume mount needed when importing public keys
56+
docker run --rm -v $(pwd)/backups:/data user2k20/imapbackup \
57+
-s imap.example.com -u user@example.com -e \
58+
--gpg-encrypt --gpg-recipient=backup@example.com \
59+
--gpg-import-key=https://example.com/public-key.asc
60+
```
61+
62+
See [GPG Key Import Guide](gpg-key-import.md) for details.
63+
64+
**Method 2**: Mount GPG keyring (traditional, needed for restore/decryption):
5365

5466
```bash
5567
-v ~/.gnupg:/root/.gnupg:ro
5668
```
5769

58-
Note: Use `:ro` (read-only) for security if you only need decryption.
70+
Note: Use `:ro` (read-only) for security. This is required for **restore operations** which need the private key.
5971

6072
## Environment Variables
6173

@@ -153,7 +165,28 @@ docker run --rm \
153165
--s3-secret-key=YOUR_SECRET_KEY
154166
```
155167

156-
### Backup with S3 and GPG Encryption
168+
### Backup with S3 and GPG Encryption (Flexible Key Import)
169+
170+
**Recommended**: Use `--gpg-import-key` for easier setup:
171+
172+
```bash
173+
docker run --rm \
174+
-v $(pwd)/backups:/data \
175+
user2k20/imapbackup \
176+
-s imap.example.com \
177+
-u user@example.com \
178+
-e \
179+
--s3-upload \
180+
--s3-endpoint=https://play.min.io:9000 \
181+
--s3-bucket=encrypted-backups \
182+
--s3-access-key=$MINIO_ACCESS_KEY \
183+
--s3-secret-key=$MINIO_SECRET_KEY \
184+
--gpg-encrypt \
185+
--gpg-recipient=backup@example.com \
186+
--gpg-import-key=https://example.com/keys/backup-public.asc
187+
```
188+
189+
**Traditional method** (mount GPG keyring):
157190

158191
```bash
159192
docker run --rm \

docs/gpg-setup.md

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
Complete guide for setting up GPG encryption for secure email backups.
44

5+
> **💡 New Feature**: For Docker users, check out the [GPG Key Import Guide](gpg-key-import.md) for a simpler way to use GPG encryption without mounting keyrings. You can now import public keys from files, URLs, or environment variables using `--gpg-import-key`.
6+
57
## Table of Contents
68

79
- [Why Use GPG Encryption](#why-use-gpg-encryption)
@@ -208,7 +210,64 @@ gpg --list-secret-keys
208210
209211
## Using GPG with Docker
210212
211-
### Share GPG Keyring with Container
213+
### Method 1: Flexible Key Import (Recommended)
214+
215+
**No keyring mount needed** - Import public keys from files, URLs, or environment variables:
216+
217+
```bash
218+
# From URL (great for automation)
219+
docker run --rm \
220+
-v $(pwd)/backups:/data \
221+
user2k20/imapbackup \
222+
-s imap.example.com \
223+
-u user@example.com \
224+
-e \
225+
--s3-upload \
226+
--s3-endpoint=https://s3.hetzner.cloud \
227+
--s3-bucket=encrypted-backups \
228+
--s3-access-key=$S3_KEY \
229+
--s3-secret-key=$S3_SECRET \
230+
--gpg-encrypt \
231+
--gpg-recipient=backup@example.com \
232+
--gpg-import-key=https://example.com/keys/backup-public.asc
233+
234+
# From environment variable
235+
export GPG_PUBLIC_KEY=$(cat ~/keys/backup-public.asc)
236+
docker run --rm \
237+
-v $(pwd)/backups:/data \
238+
-e GPG_PUBLIC_KEY \
239+
user2k20/imapbackup \
240+
-s imap.example.com \
241+
-u user@example.com \
242+
-e \
243+
--gpg-encrypt \
244+
--gpg-recipient=backup@example.com \
245+
--gpg-import-key=env:GPG_PUBLIC_KEY
246+
247+
# From file in Docker image
248+
docker run --rm \
249+
-v $(pwd)/backups:/data \
250+
-v $(pwd)/backup-public.asc:/etc/gpg-key.asc:ro \
251+
user2k20/imapbackup \
252+
-s imap.example.com \
253+
-u user@example.com \
254+
-e \
255+
--gpg-encrypt \
256+
--gpg-recipient=backup@example.com \
257+
--gpg-import-key=/etc/gpg-key.asc
258+
```
259+
260+
**Benefits**:
261+
- No GPG keyring management
262+
- Public keys are safe to distribute
263+
- Perfect for containers and automation
264+
- Works with Kubernetes ConfigMaps
265+
266+
See the [GPG Key Import Guide](gpg-key-import.md) for complete examples and workflows.
267+
268+
### Method 2: Share GPG Keyring with Container (Traditional)
269+
270+
Mount your GPG directory (useful when you have existing keyrings):
212271
213272
```bash
214273
# Mount GPG directory (read-only recommended)
@@ -228,6 +287,8 @@ docker run --rm \
228287
--gpg-recipient=backup@example.com
229288
```
230289
290+
**Note**: This method requires managing GPG permissions and is needed for **restore/decryption** (which requires the private key).
291+
231292
### Fix GPG Permissions
232293
233294
```bash

0 commit comments

Comments
 (0)