承接 moistcake/db-backup 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

moistcake/db-backup

Composer 安装命令:

composer require moistcake/db-backup

包简介

Database backup to Google Drive for Laravel projects.

README 文档

README

Laravel Database Backup is a Laravel package that provides an easy way to back up your MySQL database and upload the backup file directly to Google Drive.

🚀 Features

  • MySQL database backup using spatie/db-dumper
  • Direct upload to Google Drive using google/apiclient
  • Configurable backup directory, file prefix, and folder ID
  • Exclude specified tables from backup
  • Retains a specified number of local backups

📦 Installation

Require the package via Composer:

composer require moistcake/db-backup

⚙️ Configuration

  1. Publish the configuration file:
php artisan vendor:publish --tag=dbbackup-config
  1. Set the following environment variables in your .env file:
DB_BACKUP_CONNECTION=mysql
GOOGLE_DRIVE_CREDENTIALS=path/to/credentials.json
GOOGLE_DRIVE_FOLDER_ID=your_google_drive_folder_id
  1. Customize config/db-backup.php as needed.

💡 Usage

Run the backup command:

php artisan moistcake:db-backup

The command will:

  • Back up the database
  • Upload the backup file to Google Drive
  • Retain only the number of local backups specified in the config

📝 Logging Details

The package uses Laravel's logging system to provide detailed information about:

  • Backup initiation and completion times
  • Upload status and file URL on Google Drive
  • Error messages in case of failures

Example log entries:

[2025-04-07 16:02:43] local.INFO: ----------------------------------------------------------------------  
[2025-04-07 16:02:47] local.INFO: Database Name: database_name  
[2025-04-07 16:02:47] local.INFO: Starting Database Backup...  
[2025-04-07 16:02:48] local.INFO: Database backup completed in 6 seconds.  
[2025-04-07 16:02:48] local.INFO: Uploading Database to Google Drive...  
[2025-04-07 16:02:59] local.INFO: https://drive.google.com/file/d/abc123/view  
[2025-04-07 16:02:59] local.INFO: Database upload completed in 360 seconds.  
[2025-04-07 16:02:59] local.INFO: ----------------------------------------------------------------------  

🛠 Configuration Options

config/db-backup.php:

return [
    'database' => [
        // Specifies the database connection to use for backups
        'connection' => env('DB_BACKUP_CONNECTION', 'mysql'),

        // Tables to exclude from the backup to reduce size and time
        'exclude_tables' => [
        ],

        // Extra options to pass to the database dump command
        'extra_options' => [
            '--single-transaction',
            '--quick',
            '--routines',
            '--events',
            '--skip-lock-tables',
        ],
    ],

    // Prefix for naming backup files
    'file_prefix' => strtolower(env('APP_NAME')),

    // Directory where backups will be stored locally
    'backup_directory' => storage_path('app' . DIRECTORY_SEPARATOR . 'db_backups'),

    // Number of backup files to keep before deleting the oldest ones
    'keep_backup_count' => 2,

    // Credentials for Google Drive API for uploading backups
    'google_drive_credentials' => env('GOOGLE_DRIVE_CREDENTIALS'),

    // Folder ID in Google Drive where backups will be stored
    'google_drive_folder_id' => env('GOOGLE_DRIVE_FOLDER_ID'),

    // Size of chunks to use when uploading to Google Drive
    'google_drive_chunk_size' => 262144, // 256KB

    'logging' => [
        // Logging channel to use for backup logs
        'channel' => 'dbbackup', 

        // Logging level for backup operations
        'level' => 'info',

        // Path to the log file for backup processes
        'path' => storage_path('logs/dbbackup.log'),
    ],
];

📝 License

The MIT License (MIT). Please see License File for more information.

🤝 Contributing

Feel free to submit issues or pull requests. Contributions are welcome!

🙌 Credits

📧 Contact

For inquiries or support, open an issue or contact the maintainer at [muizshukri06@gmail.com].

moistcake/db-backup 适用场景与选型建议

moistcake/db-backup 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 72 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 02 月 24 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 moistcake/db-backup 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 moistcake/db-backup 我们能提供哪些服务?
定制开发 / 二次开发

基于 moistcake/db-backup 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

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