Open Source Database Backup package with Laravel

in #utopian-io6 years ago (edited)

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 your app.php file.
  • 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.

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 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.
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

Sort:  

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

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • Seems like you contribute quite often. AMAZING!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

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) :

Award for the number of upvotes received

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

By upvoting this notification, you can help all Steemit users. Learn how here!

Coin Marketplace

STEEM 0.20
TRX 0.13
JST 0.030
BTC 64689.90
ETH 3450.92
USDT 1.00
SBD 2.50