PHPackages                             mccool/database-backup - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. mccool/database-backup

Abandoned → [backup-manager/backup-manager](/?search=backup-manager%2Fbackup-manager)Library

mccool/database-backup
======================

A framework-agnostic driver-based database backup package with a Laravel add-on.

1.0.2(11y ago)12621.4k11[5 issues](https://github.com/ShawnMcCool/database-backup/issues)[2 PRs](https://github.com/ShawnMcCool/database-backup/pulls)MITPHPPHP &gt;=5.3.0

Since Dec 18Pushed 5y ago11 watchersCompare

[ Source](https://github.com/ShawnMcCool/database-backup)[ Packagist](https://packagist.org/packages/mccool/database-backup)[ RSS](/packages/mccool-database-backup/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (7)Versions (5)Used By (0)

> This package is abandoned. This [Backup Manager](https://github.com/backup-manager) has fully replaced it.

Database Backup
===============

[](#database-backup)

A framework-agnostic database backup package.

**Drivers:** At this moment the package supports MySQL, gzip, and Amazon S3. However, it's modular and could be extended to support much more.

**Frameworks:** This package doesn't require a framework, but a Laravel service provider and Artisan command are made available for convenience.

Note: be aware that this package uses `mysqldump` for MySQL backups.

Example
=======

[](#example)

Laravel users can run the following command if they'd like to backup the db, gzip it, upload it to s3, and remove the local backup file:

```
php artisan db:backup --s3-bucket=whatever --s3-path=/this/is/optional/ --cleanup --gzip
```

Non-Laravel users can look at the Usage section below.

Requirements
============

[](#requirements)

- 5.4 (would openly accept pull requests to lower to 5.3)

Installation
============

[](#installation)

Laravel
-------

[](#laravel)

1. add to composer.json

    ```
    "mccool/database-backup": "1.0.1"
    ```
2. install dependency

    ```
    composer update
    ```
3. install configuration file

    ```
    php artisan config:publish mccool/database-backup
    ```
4. add service provider to config/app.php

    ```
    'McCool\DatabaseBackup\ServiceProviders\LaravelServiceProvider',
    ```
5. add key / secret to the config file in `app/config/packages/mccool/database-backup/aws.php`

Native PHP
----------

[](#native-php)

1. add to composer.json

    ```
    "mccool/database-backup": "dev-master"
    ```
2. install dependency

    ```
    composer update
    ```
3. make sure that your app requires the composer autoloader

    ```
    require '../vendor/autoload.php';
    ```

Usage
=====

[](#usage)

Laravel
-------

[](#laravel-1)

**Dump the database to app/storage/dumps/databasename\_timestamp.sql**

```
php artisan db:backup
```

**Store the database to backups/databasename\_timestamp.sql**

```
php artisan db:backup --local-path=backups
```

**Gzip the database.**

```
php artisan db:backup --gzip
```

**Choose a database to dump other than the default (names are configured in Laravel's config/database.php).**

```
php artisan db:backup --database=otherdatabaseconnection
```

**Choose a specific filename other than the default (default is 'Y-m-d\_H-i-s' ). Note, do not include the file extension .sql, we will do that for you**

```
php artisan db:backup --filename=my_project_backup
```

**Upload the backup to S3**

```
php artisan db:backup --s3-bucket=whatever --s3-path=/this/is/optional/
```

**Cleanup file when we're done**

```
php artisan db:backup --s3-bucket=whatever --s3-path=/this/is/optional/ --cleanup
```

Native PHP
----------

[](#native-php-1)

```
