2017 © Pedro Peláez
 

phpunit dynamic-mysql-db-backup

Dynamic save mysql dumps to your specific Storage

image

luiz-albertoni/dynamic-mysql-db-backup

Dynamic save mysql dumps to your specific Storage

  • Thursday, August 24, 2017
  • by luiz.albertoni
  • Repository
  • 1 Watchers
  • 0 Stars
  • 408 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 8 % Grown

The README.md

DynamicMysqlDataBaseBackup

Overview

The DynamicMysqlDatabaseBackup is a Laravel package to dynamically take a dump from your Mysql database and storage to a filesystem (local filesystems, Amazon S3, and Rackspace Cloud Storage). It also allow the user to configurate which environment (local, dev, stage, prod) it should take a dump, permit the user storage the dump compressing to Zip format and the user is able to configure how many days the dump file should remain in the storage, so it dynamically storage and remove the backup files through Laravel's Scheduler., (*1)

Install

Composer install, (*2)

composer require luiz-albertoni/dynamic-mysql-db-backup

Edit app/config/app.php to add the DynamicMysqlDumpServiceProvider under the 'providers' Array, (*3)

Albertoni\DynamicMysqlDataBaseBackup\DynamicMysqlDumpServiceProvider::class,

Publish the configuration, (*4)

php artisan vendor:publish --provider="Albertoni\DynamicMysqlDataBaseBackup\DynamicMysqlDumpServiceProvider" --tag='config' --force

Set Scheduler to run the package. Add the code below in App\Console\Kernel inside the schedule method., (*5)

 $schedule->call(function () {
            DynamicMysqlFacade::runDump();
        })->daily();

Configuration File

Config file name : dynamic-mysql-dump.php, (*6)

<?php
return [
    /*
    |--------------------------------------------------------------------------
    | Dynamic Mysql Dump Configuration
    |--------------------------------------------------------------------------
    */

    'store_days' => 5,

    'specific_storage_type' => 'local',

    'specific_storage_path' => '',

    'use_zip' =>  true,

    'use_for_app_env' =>  ['local', 'dev', 'prod'],
];

What means each configuration var?, (*7)

  • store_days : Number of days which we want to hold the dump file. Default value = 5, (*8)

  • specific_storage_type: Which filesystem we are using for storage teh dump file. Default value = local, (*9)

  • specific_storage_path: Specific path that we want to store the dump file in our filesystem. Default value = '', (*10)

  • use_zip: Signal to inform if it should be compress to the Zip format, (*11)

  • use_for_app_env: Specific under which enviroment the package should take a dump, (*12)

Dependencies

To use this package we are assuming: - The application is using the Laravel Framework - The application has a Mysql database installed - The application is using one FileSystem ( https://laravel.com/docs/5.4/filesystem ) - The keys below exist in the .env file: DB_PASSWORD, DB_USERNAME, DB_DRIVER, DB_HOST, DB_DATABASE., (*13)

Advices

In the Scheduler Class do not forget to: - Import the DynamicMysqlFacade - Make sure already configurate the Cron entry to your server ( https://laravel.com/docs/5.4/scheduling ), (*14)

To do

  • Create a command to run the scheduler, beside use the Facade
  • Expand this code to handle different databases;

The Versions

24/08 2017

dev-master

9999999-dev

Dynamic save mysql dumps to your specific Storage

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar luiz.albertoni

database laravel mysql dump