PHPackages                             greathimansh/backup-auto-detect-database - 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. greathimansh/backup-auto-detect-database

ActiveLibrary

greathimansh/backup-auto-detect-database
========================================

Backup MySQL and MongoDB databases and upload to Google Drive automatically.

v1.0.5(11mo ago)224MITPHPPHP ^8.1

Since Jun 8Pushed 11mo agoCompare

[ Source](https://github.com/greathimanshu/backup-auto-detect-database)[ Packagist](https://packagist.org/packages/greathimansh/backup-auto-detect-database)[ RSS](/packages/greathimansh-backup-auto-detect-database/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (3)Versions (7)Used By (0)

📦 BackupAutoDetectDatabase
==========================

[](#-backupautodetectdatabase)

Automatically backup **MySQL** or **MongoDB** databases and upload them to **Google Drive**, as a reusable Laravel package.

> 👑 Package by: [greatHimanshu](https://github.com/greatHimanshu)

---

🚀 Features
----------

[](#-features)

- 🔐 Secure upload to Google Drive using a **Service Account**
- 💾 Auto-detect MySQL or MongoDB and perform dump
- ☁️ Upload `.sql` or `.archive` file to Drive
- 🧹 Auto-delete local files after upload
- 🔄 Ready for Laravel scheduler integration
- 🧩 Easy to install and use

---

📥 Installation
--------------

[](#-installation)

### 1. Require the package via Composer

[](#1-require-the-package-via-composer)

```
composer require greathimansh/backup-auto-detect-database
```

---

⚙️ Laravel Usage
----------------

[](#️-laravel-usage)

### 1. Publish config (optional)

[](#1-publish-config-optional)

```
php artisan vendor:publish --tag=backup-auto-detect-config
```

This will publish a config file: `config/backup-auto-detect.php`

### 2. Add Service Account JSON file

[](#2-add-service-account-json-file)

Place your Google Drive service account key file here:

```
storage/app/google/service-account.json

```

---

🛠 Configuration (`.env`)
------------------------

[](#-configuration-env)

Add these entries:

```
GOOGLE_DRIVE_FOLDER_ID=your_drive_folder_id_here        # ✅ Required — Google Drive folder ID
DB_BACKUP_TYPE=mysql                                     # ✅ Required — mysql or mongodb

MYSQLDUMP_PATH=your_mysql_dump_path_here                 # 🔁 Optional — full path if mysqldump is not in system PATH
MONGODUMP_PATH=your_mongodb_dump_path_here               # 🔁 Optional — full path if mongodump is not in system PATH

BACKUP_REPLACE=true                                      # 🔁 Optional — if true, will delete old backup before uploading new
```

---

▶️ Run the Command
------------------

[](#️-run-the-command)

Use the built-in Artisan command:

```
php artisan backup:auto-upload
```

Example output:

```
Starting database backup...
Detected: MySQL
Dumping all databases...
Uploading to Google Drive...
✅ Upload complete. Local file deleted.

```

---

🔁 Automate with Laravel Scheduler
---------------------------------

[](#-automate-with-laravel-scheduler)

In `app/Console/Kernel.php`:

```
$schedule->command('backup:auto-upload')->dailyAt('02:00');
```

Run scheduler every minute via cron (Linux):

```
* * * * * cd /path-to-project && php artisan schedule:run >> /dev/null 2>&1
```

On Windows, use Task Scheduler.

---

🧩 Supported Versions
--------------------

[](#-supported-versions)

- PHP 8.1+
- Laravel 9, 10, 11, 12
- MySQL via `mysqldump`
- MongoDB via `mongodump`

Ensure `mysqldump` or `mongodump` is available in system `PATH` or provide full path in the config.

---

📂 Where does it store backups?
------------------------------

[](#-where-does-it-store-backups)

- Files are uploaded to your **Google Drive folder**
- Filename format: `all-databases-backup.sql` or `.archive` (MongoDB)

---

🧑‍💻 Contributing
----------------

[](#‍-contributing)

PRs are welcome. Make sure your code is clean, PSR-4 compliant, and properly documented.

---

👨‍🎓 Author
----------

[](#‍-author)

**greatHimanshu**
🔗 [GitHub](https://github.com/greatHimanshu)

---

🛡 License
---------

[](#-license)

This package is licensed under the [MIT License](LICENSE).

###  Health Score

32

—

LowBetter than 71% of packages

Maintenance54

Moderate activity, may be stable

Popularity9

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~0 days

Total

6

Last Release

335d ago

PHP version history (2 changes)v1.0.0PHP ^8.2

v1.0.1PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/646f74679581bc53ec6831235f5cc84727bb50f29034c9a1fdf6b41dd33f8f55?d=identicon)[greathimanshu](/maintainers/greathimanshu)

---

Top Contributors

[![greathimanshu](https://avatars.githubusercontent.com/u/52270619?v=4)](https://github.com/greathimanshu "greathimanshu (10 commits)")

### Embed Badge

![Health badge](/badges/greathimansh-backup-auto-detect-database/health.svg)

```
[![Health](https://phpackages.com/badges/greathimansh-backup-auto-detect-database/health.svg)](https://phpackages.com/packages/greathimansh-backup-auto-detect-database)
```

###  Alternatives

[spatie/laravel-backup

A Laravel package to backup your application

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

Quickly dump and load databases

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

Core Framework and Resources for Fleetbase API

1225.0k10](/packages/fleetbase-core-api)

PHPackages © 2026

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