bancuadrian/mysqlbackup

Backup your mysql databases

0.0.3 2015-12-04 13:04 UTC

This package is not auto-updated.

Last update: 2024-06-08 16:59:31 UTC


README

alt tag Latest Stable Version Latest Unstable Version License Total Downloads

Simple Mysql Backup Package

I wrote this simple package, so I can swiftly dump my database whenever I need to. Also, in conjunction with Laravel 5 console commands, you can quickly setup a backup schedule. If you have the time, you can make your own implementation of PersistenceInterface, and save the dumps to S3/Google Drive/etc.

Requirements

  • php 5.5+
  • mysqldump

Instalation

composer require bancuadrian/mysqlbackup

Usage

You can use the BackupService class to quickly start dumping databases.

  <?php
      $backupStatus = \BancuAdrian\MysqlBackup\BackupService::backup('username','password',['database1','database2'],'/path/to/backup');
  ?>

$backupStatus returns true if all are successful, or false otherwise.

Usage Laravel 5.*

After composer require, add this line to your config/app.php , providers section.

  BancuAdrian\MysqlBackup\Support\ServiceProvider::class

If you want an alias, you can add this to the alias array

  'BackupManager' => BancuAdrian\MysqlBackup\Support\Facade::class

Publish the config file

  php artisan vendor:publish --provider="BancuAdrian\MysqlBackup\Support\ServiceProvider"

You can now find the config in config/mysqlbackup.php . Edit it to suite your needs.

You can then backup your databases using:

  \BackupManager::backupAll();
  // or for single database
  \BackupManager::backup('databaseName');

Features to come (soon I hope)

  • Restore
  • Backup to Google Drive
  • Backup to S3
  • Limit the number of backups in a folder
  havefun() && contribute() && !criticize() && give_advice();