A lightweight PHP utility to automatically compress and archive files when they reach a defined size threshold.
- β Compresses files >50MB (default) using 7Zip or fallback to Zip
- β Recursive directory scanning (includes subfolders)
- β Configurable retention policy and compression settings
- β Zero dependencies β pure PHP CLI tool
php logpacker.php /target/directory/
- Scans
/target/directory/
and all subfolders - Compresses files exceeding
max_file_size_MB
(default: 50MB) - Maintains
num_files_archived
versions (default: 5) - Oldest archives are automatically deleted
To customize, create a logpacker.ini
file in the script's root directory:
; logpacker.ini
num_files_archived = 5 ; Number of archived versions to keep
max_file_size_MB = 50 ; Minimum file size to trigger compression (in MB)
days_last_change = 0 ; [TODO] Archive files modified X days ago
days_from_creation = 0 ; [TODO] Archive files created X days ago
archive_extension = 7z ; Compression format (7z or zip)
error.log (60MB)
error.log.1.7z (compressed)
error.log.1.7z β error.log.2.7z
error.log.2.7z β error.log.3.7z
...
error.log.5.7z β deleted (oldest archive)
- 7Zip (default, if installed on system)
- Zip (fallback if 7Zip unavailable)
Open-source under the MIT License.