rashed/database-backup

database automatic backup on user's disk

dev-master 2016-08-09 12:01 UTC

This package is not auto-updated.

Last update: 2024-05-11 17:39:49 UTC


README

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();