luiz-albertoni / dynamic-mysql-db-backup
Dynamic save mysql dumps to your specific Storage
Installs: 3 853
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:phpunit
Requires
- php: >=5.5.0
- symfony/process: >=2.7.x-dev
- vlucas/phpdotenv: *
Requires (Dev)
- php: >=5.5.0
- illuminate/support: 5.1.x-dev
- mockery/mockery: *
- phpunit/phpunit: ~4.0
- vlucas/phpdotenv: *
This package is auto-updated.
Last update: 2024-12-12 05:30:27 UTC
README
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;