PHPackages                             moistcake/db-backup - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. moistcake/db-backup

ActiveLibrary[Database &amp; ORM](/categories/database)

moistcake/db-backup
===================

Database backup to Google Drive for Laravel projects.

v3.0.4(1y ago)170MITPHP

Since Feb 24Pushed 1y ago1 watchersCompare

[ Source](https://github.com/MuizShukri/db-backup)[ Packagist](https://packagist.org/packages/moistcake/db-backup)[ RSS](/packages/moistcake-db-backup/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (2)Versions (10)Used By (0)

Laravel Database Backup
=======================

[](#laravel-database-backup)

**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
----------

[](#-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
--------------

[](#-installation)

Require the package via Composer:

```
composer require moistcake/db-backup
```

---

⚙️ Configuration
----------------

[](#️-configuration)

1. **Publish the configuration file:**

```
php artisan vendor:publish --tag=dbbackup-config
```

2. **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
```

3. **Customize `config/db-backup.php` as needed.**

---

💡 Usage
-------

[](#-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
-----------------

[](#-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
-----------------------

[](#-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
---------

[](#-license)

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

---

🤝 Contributing
--------------

[](#-contributing)

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

---

🙌 Credits
---------

[](#-credits)

- [Spatie/db-dumper](https://github.com/spatie/db-dumper)
- [Google/apiclient](https://github.com/googleapis/google-api-php-client)

---

📧 Contact
---------

[](#-contact)

For inquiries or support, open an issue or contact the maintainer at \[\].

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance46

Moderate activity, may be stable

Popularity10

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 71% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~5 days

Total

9

Last Release

406d ago

Major Versions

v1.1.0 → v2.0.02025-02-26

v2.0.1 → v3.0.02025-04-07

### Community

Maintainers

![](https://www.gravatar.com/avatar/8c15ea95edaf22d97fa378229e8ee40b0b86cce08cd2e56882369c491f1a327d?d=identicon)[MuizShukri](/maintainers/MuizShukri)

---

Top Contributors

[![MuizFarmapps](https://avatars.githubusercontent.com/u/207638650?v=4)](https://github.com/MuizFarmapps "MuizFarmapps (22 commits)")[![MuizShukri](https://avatars.githubusercontent.com/u/87646034?v=4)](https://github.com/MuizShukri "MuizShukri (9 commits)")

### Embed Badge

![Health badge](/badges/moistcake-db-backup/health.svg)

```
[![Health](https://phpackages.com/badges/moistcake-db-backup/health.svg)](https://phpackages.com/packages/moistcake-db-backup)
```

###  Alternatives

[spatie/laravel-backup

A Laravel package to backup your application

6.0k21.8M191](/packages/spatie-laravel-backup)[spatie/laravel-db-snapshots

Quickly dump and load databases

1.2k2.8M20](/packages/spatie-laravel-db-snapshots)[forkcms/forkcms

Fork is an open source CMS that will rock your world.

1.2k44.5k](/packages/forkcms-forkcms)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
