devuni / notifier-package
Laravel package for automated backups and notifications.
Requires
- php: ^8.4
- guzzlehttp/guzzle: ^7.10.0
- illuminate/console: ^12.55.0 || ^13.0
- illuminate/contracts: ^12.55.0 || ^13.0
- illuminate/http: ^12.55.0 || ^13.0
- illuminate/queue: ^12.55.0 || ^13.0
- illuminate/routing: ^12.55.0 || ^13.0
- illuminate/support: ^12.55.0 || ^13.0
- laravel/prompts: ^0.3.15
Requires (Dev)
- larastan/larastan: ^3.9.3
- laravel/pint: ^1.29.0
- mockery/mockery: ^1.6.12
- nunomaduro/collision: ^8.9.1
- orchestra/testbench: ^11.0.0 || ^12.0
- pestphp/pest: ^4.4.2
- pestphp/pest-plugin-laravel: ^4.1.0
- rector/rector: ^2.3.9
- dev-main
- v2.6.0
- v2.5.0
- v2.4.3
- v2.4.2
- v2.4.1
- v2.4.0
- v2.3.4
- v2.3.3
- v2.3.2
- v2.3.1
- v2.3.0
- v2.2.6
- v2.2.5
- v2.2.4
- v2.2.3
- v2.2.2
- v2.2.1
- v2.2.0
- v2.1.3
- v2.1.2
- v2.1.1
- v2.1.0
- v2.0.2
- v2.0.1
- v2.0.0
- v1.0.27
- v1.0.26
- v1.0.25
- v1.0.24
- v1.0.23
- v1.0.22
- v1.0.21
- v1.0.20
- v1.0.19
- v1.0.18
- v1.0.17
- v1.0.16
- v1.0.15
- v1.0.14
- v1.0.13
- v1.0.12
- v1.0.11
- v1.0.10
- v1.0.9
- v1.0.8
- v1.0.7
- v1.0.6
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- v1.0.0-beta.2
- v1.0.0-beta.1
- v1.0.0-alpha.3
- v1.0.0-alpha.2
- v1.0.0-alpha.1
This package is auto-updated.
Last update: 2026-03-25 16:19:13 UTC
README
A Laravel package for automated, encrypted database and storage backups with secure remote delivery. Supports Artisan commands, HTTP API triggers, queue offloading, and AES-256 ZIP encryption out of the box.
Features
- Database backups —
mysqldumpwith--single-transactionand--quickfor consistent, low-memory dumps - Storage backups — Archives
storage/app/publicinto password-protected ZIP (AES-256) - Pluggable ZIP strategy — CLI
7z(recommended) with PHPZipArchivefallback - Chunked uploads — Large backup files split into configurable chunks (default 20 MB) for reliable transfer
- Token-based authentication —
X-Notifier-Tokenheader validated with constant-time comparison - Queue support — Offload backup jobs to any Laravel queue driver to avoid HTTP timeout limits
- Remote API trigger — Rate-limited REST endpoint to trigger backups from an external scheduler
- Exclusion lists — Ignore specific database tables and storage files/directories
- Configurable routing — Custom route prefix, or disable routes entirely
- Comprehensive logging — Dedicated configurable logging channel with automatic fallback
- Automatic cleanup — Temporary backup files removed after successful upload
Requirements
- PHP
^8.4 - Laravel
^12.2 mysqldumpbinary for database backups7z(p7zip-full) recommended for storage backups, or PHPzipextension as fallback
Installation
1. Install via Composer
composer require devuni/notifier-package
2. Publish the configuration
php artisan vendor:publish --tag="notifier-config"
This copies config/notifier.php into your application's config/ directory.
3. Configure environment variables
Run the interactive installer to write the required values to your .env:
php artisan notifier:install
4. Verify your setup
php artisan notifier:check
This command validates your environment variables, database connectivity, storage access, system tools (mysqldump, 7z), logging channel, and backup URL reachability.
Configuration
After publishing, edit config/notifier.php or set values via environment variables.
Environment Variables
# Required NOTIFIER_BACKUP_CODE=your-secret-token # Authentication token (must match the central notifier) NOTIFIER_URL=https://your-backup-server.com # Endpoint that receives backup uploads NOTIFIER_BACKUP_PASSWORD=your-zip-password # AES-256 ZIP encryption password # Optional NOTIFIER_LOGGING_CHANNEL=backup # Laravel logging channel (default: backup) NOTIFIER_ROUTES_ENABLED=true # Enable/disable the API route (default: true) NOTIFIER_ROUTE_PREFIX=api/notifier # API route prefix (default: api/notifier) NOTIFIER_ZIP_STRATEGY=auto # ZIP strategy: auto, cli, php (default: auto) NOTIFIER_CHUNK_SIZE=20971520 # Upload chunk size in bytes (default: 20 MB) NOTIFIER_QUEUE_CONNECTION=sync # Queue driver for API-triggered backups (default: sync)
All Configuration Options
| Key | Env Variable | Default | Description |
|---|---|---|---|
backup_code |
NOTIFIER_BACKUP_CODE |
— | Authentication token matched against X-Notifier-Token header |
backup_url |
NOTIFIER_URL |
— | Central notifier endpoint for backup uploads |
backup_zip_password |
NOTIFIER_BACKUP_PASSWORD |
— | Password used to encrypt backup ZIP archives |
excluded_tables |
— | [] |
Database tables excluded from backup (e.g. telescope_entries, sessions) |
excluded_files |
— | ['.gitignore'] |
Files/dirs excluded from storage backup (relative to storage/app/public) |
logging_channel |
NOTIFIER_LOGGING_CHANNEL |
backup |
Laravel log channel; falls back to daily if channel doesn't exist |
routes_enabled |
NOTIFIER_ROUTES_ENABLED |
true |
Whether to register the package's API route |
route_prefix |
NOTIFIER_ROUTE_PREFIX |
api/notifier |
URL prefix for the API route |
zip_strategy |
NOTIFIER_ZIP_STRATEGY |
auto |
ZIP strategy: auto (detect), cli (force 7z), php (force ZipArchive) |
chunk_size |
NOTIFIER_CHUNK_SIZE |
20971520 |
Upload chunk size in bytes. Keep under your proxy's limit (e.g. Cloudflare free: 100 MB) |
queue_connection |
NOTIFIER_QUEUE_CONNECTION |
sync |
Queue driver for API-triggered backups. Artisan commands always run synchronously. |
Artisan Commands
notifier:install
Interactive wizard that writes the three required environment variables to your .env file.
php artisan notifier:install
# Overwrite existing values
php artisan notifier:install --force
notifier:check
Validates the full environment and system requirements. Checks:
NOTIFIER_BACKUP_CODE,NOTIFIER_URL,NOTIFIER_BACKUP_PASSWORDare set- Database connection is healthy
storage/app/publicis accessiblemysqldumpis available on$PATH- ZIP tool is available (
7zor PHPzipextension) - Logging channel is configured
- Queue connection is set up
- Backup URL is reachable over HTTPS
php artisan notifier:check
notifier:database-backup
Creates a mysqldump of the application database and uploads it to the central notifier.
php artisan notifier:database-backup
notifier:storage-backup
Archives storage/app/public into an encrypted ZIP and uploads it to the central notifier.
php artisan notifier:storage-backup
API Endpoint
The package registers a single POST endpoint for triggering backups remotely (e.g. from a central scheduler):
POST /{route_prefix}/backup
Authentication: X-Notifier-Token header — must match NOTIFIER_BACKUP_CODE.
Rate limit: 10 requests per 60 seconds.
Request
| Parameter | Type | Required | Values |
|---|---|---|---|
type |
string | ✓ | backup_database, backup_storage |
Examples
# Trigger a database backup curl -X POST https://your-app.com/api/notifier/backup \ -H "X-Notifier-Token: your-secret-token" \ -d "type=backup_database" # Trigger a storage backup curl -X POST https://your-app.com/api/notifier/backup \ -H "X-Notifier-Token: your-secret-token" \ -d "type=backup_storage"
Response
Success (synchronous):
{
"success": true,
"message": "Database backup completed successfully.",
"backup_type": "database",
"duration_seconds": 12.34,
"timestamp": "2025-01-15T10:30:45+00:00"
}
Success (queued):
{
"success": true,
"message": "Backup job dispatched to queue.",
"backup_type": "storage",
"queued": true,
"timestamp": "2025-01-15T10:30:45+00:00"
}
Error:
{
"success": false,
"message": "Database backup failed.",
"backup_type": "database",
"error": "mysqldump: command not found",
"timestamp": "2025-01-15T10:30:45+00:00"
}
ZIP Strategy
Storage backups use AES-256 encryption regardless of the strategy chosen.
| Strategy | Tool | Memory usage | Best for |
|---|---|---|---|
auto (default) |
7z if available, else ZipArchive | — | All environments |
cli |
7z (p7zip-full) |
Low — separate process | Production servers |
php |
PHP ZipArchive |
Higher — PHP heap | Environments without 7z |
Install 7z for best performance on Linux servers:
sudo apt install p7zip-full
Queue Support
By default, API-triggered backups run synchronously inside the HTTP request. For large backups this may hit PHP's max_execution_time. Set NOTIFIER_QUEUE_CONNECTION to any async queue driver to offload backup jobs:
NOTIFIER_QUEUE_CONNECTION=database # requires php artisan queue:table NOTIFIER_QUEUE_CONNECTION=redis # requires phpredis or predis
Note: Artisan commands (
notifier:database-backup,notifier:storage-backup) always run synchronously and are not affected by this setting.
Programmatic Usage
The services can be resolved from the container or injected directly:
use Devuni\Notifier\Services\NotifierDatabaseService; use Devuni\Notifier\Services\NotifierStorageService; $db = app(NotifierDatabaseService::class); $storage = app(NotifierStorageService::class); // Database backup $path = $db->createDatabaseBackup(); $db->sendDatabaseBackup($path); // Storage backup $path = $storage->createStorageBackup(); $storage->sendStorageBackup($path);
Testing
This package uses Pest for testing.
composer test # Run all tests composer test-unit # Unit tests only composer test-feature # Feature tests only composer test-coverage # Tests with coverage report
Test Structure
tests/
├── Unit/
│ ├── Commands/ # Artisan command tests
│ ├── Controllers/ # API controller tests
│ ├── Services/ # Service class tests
│ └── NotifierServiceProviderTest.php
└── Feature/
├── BackupWorkflowTest.php
├── NotifierPackageTest.php
└── PackageInstallationTest.php
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.