Laravel Push DB
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.
I built it to ease the task of having to backup your mysql database from your laravel application.
To setup this package
- Run
composer require therealsmat/laravel-push-db
- Add
therealsmat\PushDB\PushDBServiceProvider::class
to the providers array of yourapp.php
file. - Run
php artisan vendor:publish --provider="therealsmat\PushDB\PushDBServiceProvider"
. You should get apushdb.php
file in yourconfig
directory. You can change the defaults if you wish. Also you get a new commanddb:push
automatically. Runphp artisan list
to view all available commands.
You can use this package in two ways.
- Controller
public function export(PushDB $db)
{
try{
if ($db->export()) {
return 'Database Export Successful';
}
return 'Database export not successful';
} catch (ProcessFailedException $e)
{
return $e->getMessage();
} catch (\Exception $e)
{
return $e->getMessage();
}
}
- Command
Simply runphp artisan db:push
and your database will be placed in the path you set from the pushdb.phpoutput_path
option. As simple as this command is, it can be used in several ways.
Programmatically
Artisan::call('db:push');
Optionally, Storage::disk('s3')->put('Database.sql', config('pushdb.output_path'));
Of course, you must have set up your s3 disk from the filesystems.php file.
Schedule (Automatically)
You can schedule (1) above to run automatically using Laravel Scheduler e.g
$schedule->command('db:push --force')->daily();
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.
Roadmap
In the future, i plan to
- Include support for other databases
- Implement push to cloud storage feature e.g push to Dropbox, google drive e.t.c.
How to contribute?
- Clone the repository
- Create a new branch
- Send a Pull Request with the new features
- You can send me a mail @tosinsoremekun.com
Github Link
https://github.com/therealSMAT/laravel-push-db
Posted on Utopian.io - Rewarding Open Source Contributors
Thank you for the contribution. It has been approved. A great tool and would like to see this project evolving. You can also write something to keep track of the backup by having some sort of dashboard.
You can contact us on Discord.
[utopian-moderator]
Hi, nice idea about the dashboard. I will surely extend it's functionality. Kindly star the project and feel free to contribute.
Thanks.
Hey @therealsmat I am @utopian-io. I have just upvoted you!
Achievements
Community-Driven Witness!
I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!
Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x
Congratulations @therealsmat! You have completed some achievement on Steemit and have been rewarded with new badge(s) :
Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here
If you no longer want to receive notifications, reply to this comment with the word
STOP