sebastianfeldmann / phpbu-laravel by phpbu

Laravel backup package - integrates phpbu with the laravel artisan command line tool
5,904
19
2
Package Data
Maintainer Username: phpbu
Maintainer Contact: sebastian@phpbu.de (Sebastian Feldmann)
Package Create Date: 2015-05-18
Package Last Update: 2023-03-01
Home Page: http://phpbu.de
Language: PHP
License: MIT
Last Refreshed: 2024-11-22 03:00:47
Package Statistics
Total Downloads: 5,904
Monthly Downloads: 8
Daily Downloads: 1
Total Stars: 19
Total Watchers: 2
Total Forks: 3
Total Open Issues: 1

phpbu-laravel

Laravel backup package - integrates phpbu with the laravel artisan command line tool.

A more detailed documentation can be found in the phpbu manual.

Latest Stable Version License Build Status Scrutinizer Code Quality Code Coverage

Features

  • Creating backups
    • Directories
    • MySQL
  • Validate backups
    • Check min size
    • Comparing with previous backups
  • Sync backups to other locations
    • All Laravel filesystems
  • Cleanup your backup location
    • Delete backups older x
    • Store only x MB of backups
    • Keep only last x backups

Requirements

  • PHP 7.0
  • Laravel 5.*
  • phpbu 5.*
  • see phpbu requirements for more details

Installation

Use composer to install the package.

composer require phpbu/phpbu-laravel

Add the package ServiceProvider to your config/app.php configuration file.

'providers' => [
    ...
    /*
     * phpbu Backup Service Providers...
     */
    phpbu\Laravel\ServiceProvider::class,
];

Finally create a configuration skeleton by publishing the package.

php artisan vendor:publish --provider="phpbu\Laravel\ServiceProvider"

Configuration

After publishing the ServiceProvider a phpbu.php configuration file is created in your config directory.

<?php
return [
    /*
    |--------------------------------------------------------------------------
    | laravel configuration
    |--------------------------------------------------------------------------
    |
    | This is activated as long as you don't specify a phpbu
    | configuration file at the bottom.
    |
    */

    // no directories to backup
    // keep at least the empty array 'directories' => []

    'directories' => [
        [
            'source' => [
                'path'    => storage_path('app'),
                'options' => [],
            ],
            'target' => [
                'dirname'     => storage_path('/backup/app'),
                'filename'    => 'app-%Y%m%d-%H%i.tar',
                'compression' => 'bzip2',
            ],
            'sync' => [
                'filesystem' => 's3',
                'path'       => '/backup/app',
            ]
        ]
    ],

    // no databases to backup
    // keep at least the empty array 'databases' => []

    'databases' => [
        [
            'source' => [
                'connection' => 'mysql',
                'options'    => []
            ],
            'target' => [
                'dirname'     => storage_path('backup/db'),
                'filename'    => 'dump-%Y%m%d-%H%i.sql',
                'compression' => 'bzip2',
            ],
            'sync' => [
                'filesystem' => 's3',
                'path'       => '/backup/db',
            ]
        ],
    ],
    'config' => __FILE__,

    /*
    |--------------------------------------------------------------------------
    | phpbu configuration
    |--------------------------------------------------------------------------
    |
    | Path to a phpbu configuration file.
    | You can use a phpbu.xml or phpbu.json configuration.
    | If you use one of those the configuration above will be ignored.
    | This is deactivated by default so you can setup your backup using
    | the configuration above
    */

    'phpbu' => null,
];

Usage

Show command help information.

php artisan phpbu:backup --help

Execute the backup,

php artisan phpbu:backup

Execute a dry-run without making any changes.

php artisan phpbu:backup --phpbu-simulate