Open Source Database Backup package with Laravel


SUBMITTED BY: PimpTheRomeo

DATE: Jan. 20, 2018, 5:05 p.m.

FORMAT: Text only

SIZE: 2.4 kB

HITS: 628

  1. Laravel Push DB
  2. This package allows you to easily export your database. It also provides an artisan command,php artisan db:push to make the process simpler. You can either run manually from the console or use with Laravel scheduler. It's totally a matter of choice.
  3. I built it to ease the task of having to backup your mysql database from your laravel application.
  4. To setup this package
  5. Run composer require therealsmat/laravel-push-db
  6. Add therealsmat\PushDB\PushDBServiceProvider::class to the providers array of your app.php file.
  7. Run php artisan vendor:publish --provider="therealsmat\PushDB\PushDBServiceProvider". You should get a pushdb.php file in your config directory. You can change the defaults if you wish. Also you get a new command db:push automatically. Run php artisan list to view all available commands.
  8. You can use this package in two ways.
  9. Controller
  10. public function export(PushDB $db)
  11. {
  12. try{
  13. if ($db->export()) {
  14. return 'Database Export Successful';
  15. }
  16. return 'Database export not successful';
  17. } catch (ProcessFailedException $e)
  18. {
  19. return $e->getMessage();
  20. } catch (\Exception $e)
  21. {
  22. return $e->getMessage();
  23. }
  24. }
  25. Command
  26. Simply run php artisan db:push and your database will be placed in the path you set from the pushdb.php output_path option. As simple as this command is, it can be used in several ways.
  27. Programmatically
  28. Artisan::call('db:push');
  29. Optionally, Storage::disk('s3')->put('Database.sql', config('pushdb.output_path'));
  30. Of course, you must have set up your s3 disk from the filesystems.php file.
  31. Schedule (Automatically)
  32. You can schedule (1) above to run automatically using Laravel Scheduler e.g
  33. $schedule->command('db:push --force')->daily();
  34. The package was built using laravel and is intended to work with mysql databases (for now). It uses symfony's process component to execute a mysql command.
  35. Roadmap
  36. In the future, i plan to
  37. Include support for other databases
  38. Implement push to cloud storage feature e.g push to Dropbox, google drive e.t.c.
  39. How to contribute?
  40. Clone the repository
  41. Create a new branch
  42. Send a Pull Request with the new features
  43. You can send me a mail@tosinsoremekun.com
  44. Github Link
  45. https://github.com/therealSMAT/laravel-push-db

comments powered by Disqus