PHPackages                             prodhan/laravel-backup-google-drive - 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. [File &amp; Storage](/categories/file-storage)
4. /
5. prodhan/laravel-backup-google-drive

ActiveLibrary[File &amp; Storage](/categories/file-storage)

prodhan/laravel-backup-google-drive
===================================

Laravel Backup with Google Drive integration wrapper package

v1.0.0(5mo ago)07MITPHPPHP ^8.1

Since Dec 2Pushed 5mo agoCompare

[ Source](https://github.com/prodhan/laravel-backup-google-drive)[ Packagist](https://packagist.org/packages/prodhan/laravel-backup-google-drive)[ Docs](https://github.com/prodhan/laravel-backup-google-drive)[ RSS](/packages/prodhan-laravel-backup-google-drive/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (5)Versions (2)Used By (0)

Laravel Backup Google Drive
===========================

[](#laravel-backup-google-drive)

[![Latest Version on Packagist](https://camo.githubusercontent.com/9280b6b2e6d7fa408dd33c3154a026c6a61d42d5d9d68866f809b1261a7744db/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f70726f6468616e2f6c61726176656c2d6261636b75702d676f6f676c652d64726976652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/prodhan/laravel-backup-google-drive)[![Total Downloads](https://camo.githubusercontent.com/b5dee58262be7ea0fda3833ff494a374b8d66da2776731940d8e99b799c2c952/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f70726f6468616e2f6c61726176656c2d6261636b75702d676f6f676c652d64726976652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/prodhan/laravel-backup-google-drive)[![License](https://camo.githubusercontent.com/49fad13b26442199e45d08d165f0a9716fdbe80936360253ce060a4387d0455a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f70726f6468616e2f6c61726176656c2d6261636b75702d676f6f676c652d64726976652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/prodhan/laravel-backup-google-drive)

A Laravel package that provides seamless integration between [Spatie Laravel Backup](https://github.com/spatie/laravel-backup) and Google Drive using [masbug/flysystem-google-drive-ext](https://github.com/masbug/flysystem-google-drive-ext).

Features
--------

[](#features)

- ✅ Easy Google Drive filesystem integration
- ✅ Backup uploaded files to Google Drive
- ✅ Debug tools for Google Drive connection
- ✅ Automatic cleanup of old backup files
- ✅ Works with Spatie Laravel Backup package
- ✅ Support for folder IDs and folder names

Installation
------------

[](#installation)

You can install the package via Composer:

```
composer require prodhan/laravel-backup-google-drive
```

The package will automatically register its service provider and commands.

### Alternative: Install from GitHub

[](#alternative-install-from-github)

If you prefer to install directly from GitHub:

```
composer require prodhan/laravel-backup-google-drive:dev-main
```

Or add to your `composer.json`:

```
{
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/prodhan/laravel-backup-google-drive.git"
        }
    ],
    "require": {
        "prodhan/laravel-backup-google-drive": "dev-main"
    }
}
```

Configuration
-------------

[](#configuration)

### 1. Publish Configuration (Optional)

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

```
php artisan vendor:publish --tag=backup-google-drive-config
```

### 2. Configure Google Drive in `config/filesystems.php`

[](#2-configure-google-drive-in-configfilesystemsphp)

Add the Google Drive disk configuration:

```
'disks' => [
    // ... other disks

    'google' => [
        'driver' => 'google',
        'clientId' => env('GOOGLE_DRIVE_CLIENT_ID'),
        'clientSecret' => env('GOOGLE_DRIVE_CLIENT_SECRET'),
        'refreshToken' => env('GOOGLE_DRIVE_REFRESH_TOKEN'),
        'folderId' => env('GOOGLE_DRIVE_FOLDER_ID'), // Recommended
        'folder' => env('GOOGLE_DRIVE_FOLDER'), // Alternative to folderId
    ],
],
```

### 3. Configure Spatie Backup in `config/backup.php`

[](#3-configure-spatie-backup-in-configbackupphp)

Update the backup destination:

```
'destination' => [
    'disks' => [
        'google', // Add 'google' to your backup disks
    ],
],

'backup' => [
    'name' => env('BACKUP_NAME', ''), // Empty string to save directly in folder
    // ... other config
],
```

### 4. Set Environment Variables

[](#4-set-environment-variables)

Add to your `.env` file:

```
GOOGLE_DRIVE_CLIENT_ID=your-client-id
GOOGLE_DRIVE_CLIENT_SECRET=your-client-secret
GOOGLE_DRIVE_REFRESH_TOKEN=your-refresh-token
GOOGLE_DRIVE_FOLDER_ID=your-folder-id
```

Getting Google Drive Credentials
--------------------------------

[](#getting-google-drive-credentials)

1. Go to [Google Cloud Console](https://console.cloud.google.com/)
2. Create a new project or select existing one
3. Enable Google Drive API
4. Create OAuth 2.0 credentials (Desktop app)
5. Use OAuth 2.0 Playground to get refresh token:
    - Go to [OAuth 2.0 Playground](https://developers.google.com/oauthplayground/)
    - Select "Drive API v3"
    - Authorize and get refresh token

Getting Folder ID
-----------------

[](#getting-folder-id)

1. Open Google Drive in your browser
2. Navigate to the folder you want to use
3. The folder ID is in the URL: `https://drive.google.com/drive/folders/FOLDER_ID_HERE`
4. Or use the debug command: `php artisan google-drive:debug --list-folders`

Usage
-----

[](#usage)

### Backup Database (Spatie Backup)

[](#backup-database-spatie-backup)

```
php artisan backup:run --only-db
```

### Backup Uploaded Files

[](#backup-uploaded-files)

```
# Backup public disk to Google Drive
php artisan backup:uploads

# Backup specific disk
php artisan backup:uploads --disk=local

# Backup specific folder
php artisan backup:uploads --path=products

# Custom filename
php artisan backup:uploads --filename=my-backup

# Different destination
php artisan backup:uploads --destination=s3
```

### Debug Google Drive Connection

[](#debug-google-drive-connection)

```
# Check credentials and connection
php artisan google-drive:debug

# List all folders
php artisan google-drive:debug --list-folders

# Find folder by name
php artisan google-drive:debug --folder-name=MyFolder

# Test write operation
php artisan google-drive:debug --test-write
```

### Cleanup Old Backups

[](#cleanup-old-backups)

```
# Delete backups older than 7 days (default)
php artisan backup:clean-uploads

# Delete backups older than 14 days
php artisan backup:clean-uploads --days=14

# Clean specific disk
php artisan backup:clean-uploads --disk=google

# Custom prefix
php artisan backup:clean-uploads --prefix=my-backup-
```

### Schedule Automatic Backups

[](#schedule-automatic-backups)

Add to `app/Console/Kernel.php`:

```
protected function schedule(Schedule $schedule): void
{
    // Database backup daily at 1 AM
    $schedule->command('backup:run --only-db')->daily()->at('01:00');

    // Uploads backup daily at 2 AM
    $schedule->command('backup:uploads')->daily()->at('02:00');

    // Cleanup old backups daily at 3 AM
    $schedule->command('backup:clean')->daily()->at('03:00');
    $schedule->command('backup:clean-uploads --days=7')->daily()->at('03:00');
}
```

Available Commands
------------------

[](#available-commands)

CommandDescription`backup:uploads`Backup uploaded files to Google Drive`google-drive:debug`Debug Google Drive connection`backup:clean-uploads`Clean up old upload backup filesRequirements
------------

[](#requirements)

- PHP &gt;= 8.1
- Laravel &gt;= 11.0
- Spatie Laravel Backup &gt;= 9.3
- masbug/flysystem-google-drive-ext &gt;= 2.4

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

Support
-------

[](#support)

For issues and questions, please open an issue on [GitHub](https://github.com/prodhan/laravel-backup-google-drive/issues).

License
-------

[](#license)

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

Credits
-------

[](#credits)

- [Ariful Islam](https://github.com/prodhan)
- [All Contributors](../../contributors)

Links
-----

[](#links)

- [Packagist](https://packagist.org/packages/prodhan/laravel-backup-google-drive)
- [GitHub Repository](https://github.com/prodhan/laravel-backup-google-drive)

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance71

Regular maintenance activity

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity43

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

161d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6d4dff83a30e01b7c67879824d0049afa3ec841f1ddc7f896dd9daaf0136ddc4?d=identicon)[prodhan](/maintainers/prodhan)

---

Top Contributors

[![prodhan](https://avatars.githubusercontent.com/u/7001442?v=4)](https://github.com/prodhan "prodhan (1 commits)")

---

Tags

spatieFlysystemlaravelbackupgoogle-drivecloud-storagebackup-automation

### Embed Badge

![Health badge](/badges/prodhan-laravel-backup-google-drive/health.svg)

```
[![Health](https://phpackages.com/badges/prodhan-laravel-backup-google-drive/health.svg)](https://phpackages.com/packages/prodhan-laravel-backup-google-drive)
```

###  Alternatives

[spatie/laravel-backup

A Laravel package to backup your application

6.0k21.8M191](/packages/spatie-laravel-backup)[spatie/laravel-google-cloud-storage

Google Cloud Storage filesystem driver for Laravel

2408.9M13](/packages/spatie-laravel-google-cloud-storage)[masbug/flysystem-google-drive-ext

Flysystem adapter for Google Drive with seamless virtual&lt;=&gt;display path translation

2631.7M14](/packages/masbug-flysystem-google-drive-ext)[zing/laravel-flysystem-obs

Flysystem Adapter for OBS

1211.2k](/packages/zing-laravel-flysystem-obs)[websight/l5-google-cloud-storage

Laravel 5 Flysystem Google Cloud Storage Service Provider

3662.2k](/packages/websight-l5-google-cloud-storage)[private-it/flysystem-google-drive

FlySystem adapter for Google Drive (work with path)

207.8k](/packages/private-it-flysystem-google-drive)

PHPackages © 2026

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