Overview
Nguhöe EHR uses Spatie Laravel Backup to create automated backups of your database and application files. The package provides a robust solution for creating, storing, and managing backups with monitoring and notification capabilities.Configuration File
Backup configuration is located atconfig/backup.php.
Basic Configuration
Application Name
The name identifier for your backups. Used for monitoring and organization.
Source Configuration
File Backups
Directories and files to include in the backup.
Directories and files to exclude from the backup.
Whether to follow symbolic links during backup.
Skip directories that cannot be read instead of failing.
Make paths relative to this directory in the zip file. Set to
base_path() for cleaner archives.Database Backups
Database connections to backup. Uses connection names from
config/database.php.- MySQL
- MariaDB
- PostgreSQL
- SQLite
- MongoDB
Database Dump Options
Customize database dumps by adding adump key to your database connection in config/database.php:
Compress database dumps to save space.Options:
Spatie\DbDumper\Compressors\GzipCompressor::class- Gzip compressionnull- No compression
Add timestamp to database dump filename (e.g., ‘Y-m-d-H-i-s’).
Base name for database dump files.Options:
database- Use database nameconnection- Use connection name
Destination Configuration
Compression algorithm for the backup archive.Options:
ZipArchive::CM_STORE- No compression (0)ZipArchive::CM_DEFAULT- Default compressionZipArchive::CM_DEFLATE- Deflate compressionZipArchive::CM_BZIP2- Bzip2 compressionZipArchive::CM_XZ- XZ compression
Compression level from 0-9. Higher values mean better compression but slower speed.
Prefix for backup filenames.
Storage disks where backups will be stored. Must be defined in
config/filesystems.php.Storage Disk Examples
Local Storage:config/filesystems.php and .env:
Continue backup process even if some storage targets fail.
Security Configuration
Password-protect backup archives. Set in In
.env file..env:Encryption algorithm for password-protected archives.Options:
none- No encryptiondefault- AES-256 if availableaes128- AES-128aes192- AES-192aes256- AES-256
Verify backup archive can be opened and contains files after creation. Recommended for critical backups.
Directory for temporary files during backup creation.
Cleanup Configuration
Strategy for automatically cleaning up old backups.
Default Cleanup Strategy
The default strategy keeps:- All backups for a certain number of days
- Daily backups for a period after that
- Weekly backups for a period after that
- Monthly backups for a period after that
- Yearly backups for a period after that
Keep all backups for this many days.
After the initial period, keep one backup per day for this many days.
After the daily period, keep one backup per week for this many weeks.
After the weekly period, keep one backup per month for this many months.
After the monthly period, keep one backup per year for this many years.
cleanup.default_strategy.delete_oldest_backups_when_using_more_megabytes_than
int|null
default:"5000"
Delete oldest backups when total storage exceeds this size in megabytes. Set to
null for unlimited.Monitoring Configuration
Configure health checks for your backups.
Health Checks
MaximumAgeInDays: Alerts if the newest backup is older than specified days. MaximumStorageInMegabytes: Alerts if backups use more than specified storage.Notification Configuration
Configure which events trigger notifications and through which channels.
Mail Notifications
Email address to receive backup notifications.
Slack Notifications
Discord Notifications
Running Backups
Manual Backup
Create a backup manually:--only-db- Backup only the database--only-files- Backup only files--disable-notifications- Don’t send notifications
Scheduled Backups
Add toroutes/console.php or create a scheduled task:
Cleanup Old Backups
Monitor Backup Health
List Backups
Restoration Procedures
Restoring Files
- Download backup archive from storage
- Extract the archive:
- If password-protected:
- Copy files to application directory
Restoring Database
MySQL/MariaDB:- Extract database dump from backup archive
- Restore database:
Full Application Restoration
Best Practices
Production Configuration
Security Recommendations
-
Always password-protect production backups
-
Store backups offsite (S3, Dropbox, etc.)
-
Exclude sensitive development files
-
Monitor backup health
- Test restoration regularly
Storage Recommendations
- Local: Quick access, but vulnerable to server failure
- S3: Reliable offsite storage, versioning support
- Multiple disks: Best practice - local for quick restore + offsite for disaster recovery
Scheduling Recommendations
Based on data criticality:- High criticality (patient data): Every 6 hours + full daily backup
- Medium criticality: Daily backups
- Low criticality: Weekly backups
Troubleshooting
Backup Fails with Timeout
Increase PHP timeout in backup command:Large Backups
Exclude unnecessary files:Permission Errors
Ensure storage directory is writable:S3 Upload Fails
Verify AWS credentials in.env: