sukhrobnurali/laravel-db-backup 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sukhrobnurali/laravel-db-backup

最新稳定版本:v1.0.0

Composer 安装命令:

composer require sukhrobnurali/laravel-db-backup

包简介

A Laravel package for backing up MySQL and PostgreSQL databases with support for multiple storage drivers and scheduled backups.

README 文档

README

Laravel Database Backup is a robust, extensible package for Laravel that simplifies backing up your MySQL and PostgreSQL databases. Built with clean, object-oriented principles, this package offers scheduled backups, multi-storage support, and automatic cleanup of old backups.

Features

  • Scheduled Backups: Easily schedule backups daily, weekly, or monthly using Laravel's scheduler.
  • Multi-Storage Support: Store backups locally—with the option to add remote storage drivers (e.g., S3, Google Drive) in the future.
  • Automatic Cleanup: Automatically delete backups older than a specified retention period to save disk space.
  • Artisan Command: Trigger backups manually using a simple Artisan command.
  • Custom Exception Handling: Domain-specific error handling with custom exceptions.
  • Extensible Architecture: Clean, modular design for easy integration and future enhancements.

Installation

Install the package via Composer:

composer require sukhrobnurali/laravel-db-backup

Publish the configuration file:

php artisan vendor:publish --tag=config --provider="LaravelDbBackup\Providers\DatabaseBackupServiceProvider"

Configuration

The configuration file (config/backup.php) allows you to customize several aspects of the package:

  • Local Storage: Specify the directory where backups will be stored.
  • Remote Storage (Stub): Configure remote storage options for future expansion.
  • Retention Policy: Set the number of days to retain backups.
  • Scheduling: Use cron expressions to schedule your backups.
  • Notifications (Stub): Configure notification options (e.g., via Telegram) for backup events.

Usage

To manually run a backup, simply execute the Artisan command:

php artisan backup:run

To schedule automatic backups, add the command to your Laravel scheduler in app/Console/Kernel.php:

protected function schedule(Schedule $schedule)
{
    $schedule->command('backup:run')->daily();
}

Testing

This package includes a comprehensive test suite using Orchestra Testbench. To run the tests, execute:

vendor/bin/phpunit

Contributing

Contributions are welcome! To contribute:

  1. Fork the repository.
  2. Create a new branch for your feature or bug fix.
  3. Write tests and ensure that everything passes.
  4. Submit a pull request.

License

This package is open-sourced software licensed under the MIT license.

统计信息

  • 总下载量: 25
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-02-10