Download the PHP package varienos/mysql-backup without Composer
On this page you can find all versions of the php package varienos/mysql-backup. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download varienos/mysql-backup
More information about varienos/mysql-backup
Files in varienos/mysql-backup
Package mysql-backup
Short Description Modern MySQL database backup and restore utility with compression support
License MIT
Homepage https://github.com/varienos/mysql-backup
Informations about the package mysql-backup
MySQL Backup PHP
Modern, efficient MySQL database backup and restore utility for PHP 7.4+
Features
- Modern PHP: Built with PHP 7.4+ features (type hints, PDO, PSR-4 autoloading)
- Memory Efficient: Batch processing to handle large databases without exhausting memory
- Compression Support: Optional gzip compression to save disk space
- Backup & Restore: Full backup and restore functionality
- Progress Tracking: Real-time logging and progress information
- Flexible Table Selection: Backup all tables or select specific ones
- CLI & Web Compatible: Works in both command-line and web environments
- Zero Dependencies: Core functionality requires only PHP and PDO extension
Requirements
- PHP >= 7.4
- PDO MySQL extension
- MySQL/MariaDB database
Installation
Using Composer (Recommended)
Manual Installation
-
Clone or download this repository:
-
Install dependencies:
- Verify installation:
Quick Install with Make
If you have make installed:
Quick Start
Creating a Backup
Restoring from Backup
Configuration Options
Advanced Usage
Backup Specific Tables
List Available Backups
Access Logs
Examples
See the example-backup.php and example-restore.php files for complete working examples.
Running Examples
-
Ensure dependencies are installed:
-
Copy
.env.exampleto.envand configure your database credentials: -
Run the backup example:
- Run the restore example:
Available Commands
Composer Commands
Make Commands
Performance Tips
- Batch Size: Adjust
batch_sizebased on your available memory. Larger batches are faster but use more memory. - Compression: Enable gzip compression to save disk space (typically 70-90% reduction).
- Foreign Key Checks: Disable during restore for faster imports.
Testing
This package includes a comprehensive test suite using PHPUnit.
Setup Test Environment
-
Install PHPUnit (if not already installed):
-
Configure test database credentials in
phpunit.xml:Or copy
.env.testing.exampleto.env.testingand configure your test credentials. - Ensure test database user has permissions:
Running Tests
Run all tests:
Run specific test class:
Run with coverage report:
Run specific test method:
Test Coverage
The test suite covers:
- ✅ Constructor and initialization with valid/invalid credentials
- ✅ Backup all tables (empty and with data)
- ✅ Backup specific tables (array and string format)
- ✅ Restore from compressed and uncompressed backups
- ✅ Gzip compression/decompression
- ✅ Batch processing with large datasets
- ✅ List backups with metadata
- ✅ Foreign key constraint handling
- ✅ Special character escaping in data
- ✅ Error handling and exceptions
- ✅ Logging system
Writing Custom Tests
Extend the base TestCase class for database test utilities:
Security Notes
- Never commit
.envfiles or hardcode credentials in version control - Store backup files in a secure location with appropriate permissions
- Regularly test your backup and restore procedures
- Consider encrypting sensitive backup files
License
MIT License
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
For security reports or general questions, reach out at [email protected].
All versions of mysql-backup with dependencies
ext-pdo Version *
ext-pdo_mysql Version *