Skip to content

Commit c4eb23a

Browse files
committed
Refactor Backupdrop: Enhance Docker setup, implement retention policies, and improve web interface
- Updated Docker configuration to build from Dockerfile and expose port 8080. - Added non-root user for PHP-FPM and adjusted permissions for log directories. - Introduced FolderConfig and RetentionManager classes to manage backup configurations and retention policies. - Enhanced web interface with settings for password protection and retention rules. - Implemented cron script for periodic retention cleanup. - Updated upload handling to support new retention logic and file management. - Improved HTML structure and styling for better user experience. - Changed file permissions for various scripts and configuration files.
1 parent 8034a2f commit c4eb23a

32 files changed

+862
-63
lines changed

.dockerignore

100644100755
File mode changed.

.github/workflows/build-docker.yml

100644100755
File mode changed.

LICENSE

100644100755
File mode changed.

README.md

100644100755
Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,14 @@
2121

2222
# Features
2323
- Selfhostable
24+
- **Per-folder retention policies** with Proxmox-style rules (keep last N, hourly, daily, weekly, monthly, yearly)
25+
- **Password protection** per backup target via web interface
2426
- Handles backup versions by date, size and count
2527
- File based - no database needed
2628
- Supports multiple [local and cloud endpoints](/rtfm/storage.md)
2729
- Supports multiple backup sources (machines you want to back up), distinguished by hostname
30+
- Web interface for managing retention settings and viewing backups
31+
- Automated cleanup via cron script
2832
- No dependencies unless you want cloud endpoints
2933

3034
# Basics
@@ -121,4 +125,39 @@ Result:
121125
## Configuration
122126
To change default settings you need to copy or rename `/config/example.config.inc.php` to `/config/config.inc.php` and change the values as needed.
123127

124-
Check out [the example config file](/config/example.config.inc.php) to see what how you can configure BackupDrop.
128+
Check out [the example config file](/config/example.config.inc.php) to see what how you can configure BackupDrop.
129+
130+
## Per-Folder Retention & Settings
131+
132+
Each backup target can now have individual settings accessible via web interface:
133+
134+
```
135+
http://localhost:8080/[your-backup-target]
136+
```
137+
138+
Features available per target:
139+
- **Password protection** - Protect upload form and settings with a password
140+
- **Retention rules** - Proxmox-style retention (keep last N, hourly, daily, weekly, monthly, yearly)
141+
- **File tracking** - View all backups with timestamps and sizes
142+
- **Keep all option** - Disable retention to keep all backups
143+
144+
### Automated Cleanup
145+
146+
Run the cron script to apply retention policies:
147+
148+
```bash
149+
php web/cron.php
150+
```
151+
152+
Or set up automated cleanup (recommended):
153+
```bash
154+
# Run daily at 3 AM
155+
0 3 * * * php /path/to/backupdrop/web/cron.php
156+
```
157+
158+
**For Docker:**
159+
```bash
160+
0 3 * * * docker exec backupdrop-backupdrop-1 php /var/www/backupdrop/web/cron.php
161+
```
162+
163+
For detailed information, see the [retention configuration guide](/rtfm/retention-configuration.md).

config/.gitignore

100644100755
File mode changed.

config/example.config.inc.php

100644100755
File mode changed.

data/.gitignore

100644100755
File mode changed.

docker-compose-prod.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
version: '3.8'
2+
3+
services:
4+
backupdrop:
5+
image: hascheksolutions/backupdrop
6+
ports:
7+
- "8080:80"
8+
environment:
9+
# remove unneeded config options
10+
- ENCRYPTION_AGE_SSH_PUBKEY=
11+
- ENCRYPTION_AGE_PUBKEY=
12+
- S3_BUCKET=
13+
- S3_ACCESS_KEY=
14+
- S3_SECRET_KEY=
15+
- S3_ENDPOINT=
16+
- FTP_SSL=
17+
- FTP_SERVER=
18+
- FTP_PORT=
19+
- FTP_USER=
20+
- FTP_PASS=
21+
- FTP_BASEDIR=
22+
restart: unless-stopped
23+
volumes:
24+
- ./data:/var/www/backupdrop/data
25+

docker-compose.yml

100644100755
Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ version: '3.8'
22

33
services:
44
backupdrop:
5-
image: hascheksolutions/backupdrop
5+
build:
6+
context: .
7+
dockerfile: docker/Dockerfile
68
ports:
7-
- "8080:80"
9+
- "8080:8080"
810
environment:
911
# remove unneeded config options
1012
- ENCRYPTION_AGE_SSH_PUBKEY=
@@ -13,9 +15,6 @@ services:
1315
- S3_ACCESS_KEY=
1416
- S3_SECRET_KEY=
1517
- S3_ENDPOINT=
16-
- KEEP_N_BACKUPS=
17-
- KEEP_N_DAYS=
18-
- KEEP_N_GIGABYTES=
1918
- FTP_SSL=
2019
- FTP_SERVER=
2120
- FTP_PORT=
@@ -24,5 +23,5 @@ services:
2423
- FTP_BASEDIR=
2524
restart: unless-stopped
2625
volumes:
27-
- ./data:/var/www/backupdrop/data
28-
26+
- ./:/var/www/backupdrop
27+
- ./data:/var/www/backupdrop/data

docker/Dockerfile

100644100755
Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,35 @@ RUN mkdir -p /run/nginx
2121
RUN mkdir -p /var/log/nginx
2222

2323
# php stuff
24-
RUN sed -i 's/nobody/nginx/g' /etc/php83/php-fpm.d/www.conf
24+
RUN sed -i 's/nobody/backupdrop/g' /etc/php83/php-fpm.d/www.conf
25+
RUN sed -i 's/group = nobody/group = backupdrop/g' /etc/php83/php-fpm.d/www.conf
2526
RUN sed -i 's/E_ALL \& ~E_DEPRECATED \& ~E_STRICT/E_ALL \& ~E_DEPRECATED \& ~E_STRICT \& ~E_NOTICE \& ~E_WARNING/g' /etc/php83/php.ini
2627
# disable upload file size limit
2728
RUN sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 0/g' /etc/php83/php.ini
2829
RUN sed -i 's/post_max_size = 8M/post_max_size = 0/g' /etc/php83/php.ini
30+
# Fix PHP-FPM log directory
31+
RUN mkdir -p /var/log/php83 && chmod 755 /var/log/php83
2932

3033
# web interface stuff
3134
WORKDIR /var/www/backupdrop/web/lib
3235
RUN composer install
3336
WORKDIR /var/www/backupdrop/
3437

35-
EXPOSE 80
38+
# Create non-root user and set permissions
39+
RUN addgroup -g 1000 backupdrop && \
40+
adduser -D -u 1000 -G backupdrop backupdrop && \
41+
chown -R backupdrop:backupdrop /var/www/backupdrop && \
42+
chown -R backupdrop:backupdrop /var/log/nginx && \
43+
chown -R backupdrop:backupdrop /var/log/php83 && \
44+
chown -R backupdrop:backupdrop /var/lib/nginx && \
45+
chown -R backupdrop:backupdrop /run/nginx && \
46+
mkdir -p /var/log/php-fpm && \
47+
chown -R backupdrop:backupdrop /var/log/php-fpm
48+
49+
# Switch to non-root user
50+
USER backupdrop
51+
52+
EXPOSE 8080
3653
VOLUME /var/www/backupdrop/data
3754

38-
39-
#CMD ["/bin/ash"]
4055
ENTRYPOINT ["/etc/start.sh"]

0 commit comments

Comments
 (0)