2017 © Pedro Peláez
 

library db-exporter

The Simple package to export MySql database as .sql file via shell.

image

haykabrahamyan/db-exporter

The Simple package to export MySql database as .sql file via shell.

  • Friday, February 9, 2018
  • by devabrahamyan
  • Repository
  • 1 Watchers
  • 1 Stars
  • 42 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 2 % Grown

The README.md

DB-Exporter

N|Solid, (*1)

Why need to search? you are already found, follow to guide and make life happy:), (*2)

Features!

  • Export MySql database to SQL file using 'mysqldump' command in shell
  • Automatically upload dump to Google Drive
  • Laravel Storage Support

before start configuration prepare your Google oAuth credentials: - GOOGLE_DRIVE_CLIENT_ID - GOOGLE_DRIVE_CLIENT_SECRET - GOOGLE_DRIVE_REFRESH_TOKEN - GOOGLE_DRIVE_FOLDER_ID(optional), (*3)

Installation

Package requires php v5.3+ to run., (*4)

Install the dependencies and devDependencies and update composer., (*5)

"require": {
....
    "haykabrahamyan/db-exporter": "^1.0.0",
....
}

update environments as follows..., (*6)

GOOGLE_DRIVE_CLIENT_ID=xxxx-yyyyyyyyy.apps.googleusercontent.com
GOOGLE_DRIVE_CLIENT_SECRET=client_secret
GOOGLE_DRIVE_REFRESH_TOKEN=1/xxxxxx
GOOGLE_DRIVE_FOLDER_ID=null

set drive folder to null if you want to upload dump in your drive root folder, (*7)

DbExporter_MYSQLDUMP=/usr/bin/mysqldump
DbExporter_PATH=/var/www/html/public/

Configuration

Add the storage disk configuration to config/filesystem.php:, (*8)

return [

    // ...

    'cloud' => 'google', // Optional: set Google Drive as default cloud storage

    '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'),
        ],

        // ...

    ],

    // ...
];

Development

Save GoogleDriveServiceProvider.php to app/Providers and add it to the providers array in config/app.php:, (*9)

App\Providers\GoogleDriveServiceProvider::class,

GoogleDriveServiceProvider.php, (*10)

<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class GoogleDriveServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap the application services.
     *
     * @return void
     */
    public function boot()
    {
        \Storage::extend('google', function($app, $config) {
            $client = new \Google_Client();
            $client->setClientId($config['clientId']);
            $client->setClientSecret($config['clientSecret']);
            $client->refreshToken($config['refreshToken']);
            $service = new \Google_Service_Drive($client);
            $adapter = new \Hypweb\Flysystem\GoogleDrive\GoogleDriveAdapter($service, $config['folderId']);
            return new \League\Flysystem\Filesystem($adapter);
        });
    }
    /**
     * Register the application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }
}

how to use

You are done and can use now everywhere in your code including scheduled files by simple call, (*11)

DbExporterController::doExport();

Don't forget! Use the class to the head of your file where should be called Exporter, (*12)

use Haykabrahamyan\DbExporter\DbExporterController;

License

MIT, (*13)

Free Software, Good Luck! You are free to donate at 132DKpgzGfYfFgqjR9EoG8EpYyAm84ksj2 BTC address, (*14)

The Versions

09/02 2018

dev-master

9999999-dev

The Simple package to export MySql database as .sql file via shell.

  Sources   Download

MIT

The Requires

 

by Hayk Abrahamyan

08/02 2018

v1.0.4

1.0.4.0

The Simple package to export MySql database as .sql file via shell.

  Sources   Download

MIT

The Requires

 

by Hayk Abrahamyan

08/02 2018

v1.0.3

1.0.3.0

The Simple package to export MySql database as .sql file via shell.

  Sources   Download

MIT

The Requires

 

by Hayk Abrahamyan

08/02 2018

v1.0.2

1.0.2.0

The Simple package to export MySql database as .sql file via shell.

  Sources   Download

MIT

The Requires

 

by Hayk Abrahamyan