PHPackages                             kwenziwa/database-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. kwenziwa/database-backup

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

kwenziwa/database-backup
========================

A Laravel package to backup the database and upload to Google Drive.

1.0.0(11mo ago)00MITPHPPHP ^8.2

Since May 25Pushed 11mo agoCompare

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

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

📦 kwenziwa/database-backup
==========================

[](#-kwenziwadatabase-backup)

A Laravel package to automate database backups and upload them to **Google Drive**.
Seamlessly integrates with [Spatie's Laravel Backup](https://github.com/spatie/laravel-backup) and the Google API client.
Ideal for keeping your backups safe and accessible in the cloud.

---

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

[](#-features)

- 🎯 Backup your database with Spatie’s Laravel Backup
- ☁️ Upload the latest backup automatically to Google Drive
- 🔒 Fully Laravel 12+ compatible
- 🔧 Easy configuration and installation

---

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

[](#-installation)

Install the package via Composer:

```
composer require kwenziwa/database-backup
```

---

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

[](#️-configuration)

### Step 1: Publish Config

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

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

Creates `config/database-backup.php`.

---

🔑 Google API Setup
------------------

[](#-google-api-setup)

### 1️⃣ Create Google API Credentials

[](#1️⃣-create-google-api-credentials)

- Go to the [Google Cloud Console](https://console.cloud.google.com/).
- Navigate to [Service Accounts](https://console.cloud.google.com/iam-admin/serviceaccounts).
- Click **Create Service Account**.
- Follow the prompts:
    - Name: e.g., `Database Backup Service`
    - Role: Choose **Editor** (or more restricted if desired).
- After creating the service account:
    - Go to the **Keys** tab.
    - Click **Add Key → Create New Key → JSON**.
    - Download the JSON key file.

### 2️⃣ Enable Google Drive API

[](#2️⃣-enable-google-drive-api)

- Visit the [Google Drive API page](https://console.cloud.google.com/apis/library/drive.googleapis.com) and click **Enable**.
- For detailed step-by-step instructions, see this guide:
    [How to Enable Google Drive API on the Google Console](https://www.cybrosys.com/blog/how-to-enable-google-drive-api-on-the-google-console)

### 3️⃣ Save the Credentials File

[](#3️⃣-save-the-credentials-file)

Move the downloaded JSON key file to:

```
storage/app/google-drive/credentials.json

```

Ensure the path matches this in your `.env`:

```
GOOGLE_DRIVE_CREDENTIALS=storage/app/google-drive/credentials.json
```

---

📁 Set Up Google Drive Access
----------------------------

[](#-set-up-google-drive-access)

### 4️⃣ Get Your Google Drive Folder ID

[](#4️⃣-get-your-google-drive-folder-id)

- Create a folder in Google Drive (e.g., `Database Backups`).
- Right-click the folder → **Get Link** → Copy the long ID in the URL:

    Example:

    ```
    https://drive.google.com/drive/folders/1a2B3cD4EfG5hI6Jk7LmNOPQr8TuvWXy

    ```

    The **folder ID** is:

    ```
    1a2B3cD4EfG5hI6Jk7LmNOPQr8TuvWXy

    ```

Add this to your `.env`:

```
GOOGLE_DRIVE_FOLDER_ID=1a2B3cD4EfG5hI6Jk7LmNOPQr8TuvWXy
```

---

### 5️⃣ Share Folder with Service Account

[](#5️⃣-share-folder-with-service-account)

- Open your Google Drive folder.
- Click **Share**.
- In the **People** field, paste the `client_email` from your JSON file (example below).
- Give **Editor** access.

---

### 🔍 Example `credentials.json` Structure

[](#-example-credentialsjson-structure)

```
{
  "type": "service_account",
  "project_id": "your-project-id",
  "private_key_id": "your-private-key-id",
  "private_key": "-----BEGIN PRIVATE KEY-----\nABC...\n-----END PRIVATE KEY-----\n",
  "client_email": "database-backup@your-project.iam.gserviceaccount.com",
  "client_id": "1234567890",
  "auth_uri": "https://accounts.google.com/o/oauth2/auth",
  "token_uri": "https://oauth2.googleapis.com/token",
  "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
  "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/database-backup%40your-project.iam.gserviceaccount.com"
}
```

---

🚀 Usage
-------

[](#-usage)

Backup your database and upload to Google Drive:

```
php artisan google-drive:backup
```

Test Google Drive connection:

```
php artisan google-drive:test
```

---

🌍 Requirements
--------------

[](#-requirements)

- PHP 8.2+
- Laravel 10, 11, or 12
- [Spatie Laravel Backup](https://github.com/spatie/laravel-backup) v9.2.8+
- [Google API Client](https://github.com/googleapis/google-api-php-client)

---

📖 Documentation
---------------

[](#-documentation)

CommandDescription`php artisan google-drive:backup`Backup database and upload to Google Drive`php artisan google-drive:test`Test Google Drive connection and credentials`php artisan vendor:publish --tag=config`Publish the package config file---

🙌 Author
--------

[](#-author)

Developed by [Kwenziwa Khanyile](https://github.com/kwenziwa)
Feel free to contribute, submit issues, or fork the repository!

---

📄 License
---------

[](#-license)

MIT © 2024 Kwenziwa Khanyile

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance50

Moderate activity, may be stable

Popularity0

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

Unknown

Total

1

Last Release

354d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/cf73387e122d5d0617c180f7406190d2bb345dd7796e189253b01562fa19f62e?d=identicon)[Kwenziwa](/maintainers/Kwenziwa)

---

Top Contributors

[![Kwenziwa](https://avatars.githubusercontent.com/u/21169712?v=4)](https://github.com/Kwenziwa "Kwenziwa (5 commits)")

### Embed Badge

![Health badge](/badges/kwenziwa-database-backup/health.svg)

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

###  Alternatives

[wnx/laravel-backup-restore

A package to restore database backups made with spatie/laravel-backup.

203330.1k2](/packages/wnx-laravel-backup-restore)[forkcms/forkcms

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

1.2k44.5k](/packages/forkcms-forkcms)[pavel-mironchik/laravel-backup-panel

An interface for Spatie Laravel Backup package

41469.6k1](/packages/pavel-mironchik-laravel-backup-panel)

PHPackages © 2026

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