The health check script was not using the REDIS_HOST_PASSWORD environment
variable when checking Redis connectivity, causing failures when Redis is
password-protected. Now properly detects and uses the password from .env
when available.
Also includes minor cleanup in backup.sh (formatting and redundant log removal).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Final optimizations based on real Nextcloud data characteristics:
Changes:
- Reduce DB estimate from 50MB to 10MB (mysqldump is tiny vs raw files)
- Adjust compression ratio from 90% to 30% (Nextcloud has pre-compressed files)
- Files are mostly images/PDFs already compressed, gzip gains are minimal
Results progression:
- Initial: 1.7GiB required → 55MB final (97% off)
- V2: 840MiB required → 55MB final (94% off)
- V3: 130MiB required → 55MB final (58% off)
- Final: 82MiB required → 55MB final (5% off) ✓
The estimation is now extremely accurate because it accounts for:
1. Excluded directories (preview, cache, thumbnails)
2. SQL dump vs raw MySQL files difference
3. Realistic compression ratio for already-compressed files
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Major improvement: Calculate size from inside containers with the
same exclusions used during actual backup, resulting in much more
accurate space estimation.
Changes:
- Use docker-compose exec to calculate size from containers
- Apply same exclusions as tar backup (preview, cache, thumbnails)
- Calculate DB size from /var/lib/mysql directly
- Reduce default fallback from 2GB to 500MB (more realistic)
Results before/after:
- Before: 1.7GiB required → 55MB final (97% difference)
- After: 840MiB required → 55MB final (35% difference)
The estimation is now much closer to reality because we exclude
preview images, caches and thumbnails that aren't backed up.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add compressed size estimation and better error handling:
- Show both uncompressed (for safety) and estimated compressed size
- Handle calculation failure gracefully with clear message
- Estimate compression ratio at ~90% (divide by 10)
- Add conditional check to prevent arithmetic errors
Example output:
- Espace requis (non compressé + 20%): 1.7GiB
- Espace estimé après compression: 170MiB
- Archive finale: 55MiB (actual result)
This helps users understand why the required space seems larger
than the final backup size (compression factor).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Major fixes:
- Fix script structure: load .env before defining variables
- Remove duplicate color definitions (use common.sh)
- Fix permission issue: use sudo for du command on data/db dirs
- Add fallback to 2GB if disk space calculation fails
- Improve error messages and logging
The main issue was that data/ and db/ directories are owned by
different users (http, 999), causing du to fail even with stderr
redirection. Using sudo or || echo "0" fallback fixes this.
Tested: Backup now completes successfully with proper logging
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
The comparison was failing with "integer expression expected" error
because AVAILABLE_SPACE contained whitespace characters.
Changes:
- Add tr -d '[:space:]' to clean AVAILABLE_SPACE value
- Add validation for empty REQUIRED_SPACE (fallback to 1GB)
- Add validation for empty AVAILABLE_SPACE (exit with error)
- Add 2>/dev/null on comparison to prevent error messages
- Improve error handling for edge cases
Fixes: scripts/backup.sh: ligne 106 : [: 1712798932 0 : nombre entier attendu
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Update restore.sh to use common.sh instead of inline log function
- Update update.sh to use common.sh instead of inline log function
- Update recover.sh to use common.sh instead of inline log function
- Update check-health.sh to import colors from common.sh
Benefits:
- DRY principle: color definitions in one place
- Consistent logging across all scripts
- Easier maintenance: change log format once
- All scripts now have colored output in terminal
- Reduced code duplication (48 lines removed)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Create scripts/common.sh with reusable log() function and color definitions
- Refactor backup.sh to use common.sh for consistent logging
- Add color support: ERROR (red), WARN (yellow), SUCCESS (green), INFO (normal)
- Colors only appear in terminal, plain text in log files
- Improve code organization and DRY principle
- Fix shellcheck spacing warnings in backup.sh
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Security (CRITICAL):
- Add .env.example with strong password generation instructions
- Fix path traversal validation in restore.sh (now detects all .. patterns)
- Secure .env loading with set -a/set +a in all scripts
- Add logs/ to .gitignore to prevent credential leaks
Backup & Restore (IMPORTANT):
- Add file locking system to prevent concurrent backups
- Add disk space verification before backup operations
- Generate SHA256 checksums for all backups
- Verify checksums before restoration
- Create safety database backup before restore
- Implement comprehensive logging to ./logs/ directory
- Fix BACKUP_RETENTION_DAYS inconsistency
- Replace dangerous find -delete with safe iteration
Update & Recovery:
- Backup docker-compose.yml before updates with auto-rollback
- Add version display before/after updates
- Increase timeouts to 120s for slow containers
- Dynamic backup suggestion in recover.sh
Compatibility:
- Add Docker Compose v2 support with v1 fallback in all scripts
- Standardized log() function across all scripts
New Features:
- Add check-health.sh: comprehensive system health monitoring
- Add SECURITY.md: complete security documentation
- Update Makefile with check-health and recover commands
- Centralized logging with timestamps and levels
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Replace emoji-based prefixes with consistent [ERR], [WARN], and [*]
prefixes for better parsing and logging compatibility.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>