定制 basantsd/db-backup-laravel-ci 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

basantsd/db-backup-laravel-ci

最新稳定版本:v1.0.0

Composer 安装命令:

composer require basantsd/db-backup-laravel-ci

包简介

A Laravel and CI package for daily database backups sent via email

README 文档

README

A framework agnostic package to automatically back up your database and send the result via email. It supports both Laravel and CodeIgniter applications.

Features

  • Works with MySQL, PostgreSQL, SQL Server and SQLite databases
  • Creates a SQL dump and compresses it using gzip
  • Emails the compressed dump on a daily schedule
  • If the gzipped file exceeds the configured size limit (25 MB by default) it is saved to disk and a download path is emailed instead

Installation

composer require basantsd/db-backup-laravel-ci

Environment variables

Add these entries to your .env file:

BACKUP_EMAIL=your-email@example.com
BACKUP_TOKEN=your-secret-token
APP_NAME="project-name"
# Optional: override the maximum attachment size in bytes (default 26214400)
BACKUP_MAX_ATTACHMENT_SIZE=26214400

Laravel setup

  1. Publish the configuration file:
    php artisan vendor:publish --provider="Basantsd\\Backup\\Laravel\\BackupServiceProvider" --tag="config"
  2. Schedule the command in app/Console/Kernel.php:
    protected function schedule(Schedule $schedule)
    {
        $schedule->command('backup:daily', ['--token' => config('backup.token')])->daily();
    }

CodeIgniter setup

  1. Add a route to routes.php:
    $route['backup/daily'] = 'BackupController/daily';
  2. Call the route with the token header:
    curl -H "X-Backup-Token: your-secret-token" http://your-domain.com/backup/daily

Usage

Laravel

Run the artisan command:

php artisan backup:daily --token=your-secret-token

CodeIgniter

Access the /backup/daily URL with the header shown above.

Handling large backups

Many email providers reject attachments larger than 20–25 MB. When the compressed backup exceeds BACKUP_MAX_ATTACHMENT_SIZE, this package saves the file to a backups directory (storage/app/backups for Laravel or APPPATH/backups for CodeIgniter) and sends an email containing the path to download the backup manually.

License

The MIT License (MIT). Please see the LICENSE file for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-06-24