shuvrow / database-backup by shuvrow

database automatic backup on user's disk
218
1
2
Package Data
Maintainer Username: shuvrow
Maintainer Contact: shuvrow@gmail.com (Rashedul Hoque Bhuiyan)
Package Create Date: 2016-08-08
Package Last Update: 2016-08-09
Language: PHP
License: Creative Commons
Last Refreshed: 2024-04-30 15:05:31
Package Statistics
Total Downloads: 218
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 1
Total Watchers: 2
Total Forks: 0
Total Open Issues: 0

DB-Backup

Database Auto Backup For Laravel 5.2 users ##Installation

Db-backup is a laravel package. You can install it via composer.In your project directory run following command:

composer require 'rashed/database-backup':'dev-master'

##Configuration

Set directory for database backup on web server.Add DB_BACKUP on .env file as follow

####DB_BACKUP=directory_name

When download is completed, add following line on app.php file in providers section

\Rashed\Backup\DbBackupServiceProvider::class,

###publish

Now run following command from terminal

php artisan config:clear 
composer dump-autoload -o

This will publish all necessary file for this package.

Now on app/Providers/EventServiceProvider.php file add following lines in $listen variable.

'Rashed\Backup\Events\DbBackupEvent' => [
        'Rashed\Backup\Listeners\DbBackupEventListener',
    ],

Usages

Event::fire(new \Rashed\Backup\Events\DbBackupEvent());

Note:

  • Use this event to export database in your local disk.
  • This event store database on user's machine and remove it from server.
  • If you want to store database on server periodically Make sure your configure it first. Schedule Backup .

####schedule-backup

This option required configuration for db auto backup on server using task scheduling. To use this option you have to add a cron entry on your server.

* * * * * php /path/to/artisan schedule:run >> /dev/null 2>&1

After adding this, add following line on app/Console/kernel.php file:

use Rashed\Backup\Commands\Backup;

and add following line in $commands variable

Backup::class,

And on schedule() function add scheduler as your requirements.

For example if you want to backup your database after every 30 minutes write following code

$schedule->command('Backup')->everyThirtyMinutes();

backup your database after every 10 minutes , write following code :

$schedule->command('Backup')->everyTenMinutes();