luiz-albertoni / DynamicMysqlDataBaseBackup by luiz.albertoni

Dynamic save mysql dumps to your specific Storage
2,418
0
1
Package Data
Maintainer Username: luiz.albertoni
Maintainer Contact: luiz.albertoni@gmail.com (luiz.albertoni)
Package Create Date: 2017-08-07
Package Last Update: 2018-09-07
Language: PHP
License: MIT
Last Refreshed: 2024-04-18 15:05:33
Package Statistics
Total Downloads: 2,418
Monthly Downloads: 137
Daily Downloads: 7
Total Stars: 0
Total Watchers: 1
Total Forks: 0
Total Open Issues: 0

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.

Install

Composer install

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

Edit app/config/app.php to add the DynamicMysqlDumpServiceProvider under the 'providers' Array

Albertoni\DynamicMysqlDataBaseBackup\DynamicMysqlDumpServiceProvider::class,

Publish the configuration

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.

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

Configuration File

Config file name : dynamic-mysql-dump.php

<?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?

  • store_days : Number of days which we want to hold the dump file. Default value = 5

  • specific_storage_type: Which filesystem we are using for storage teh dump file. Default value = local

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

  • use_zip: Signal to inform if it should be compress to the Zip format

  • use_for_app_env: Specific under which enviroment the package should take a dump

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.

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 )

To do

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