phpbu/phpbu-laravel

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

3.0.5 2023-03-01 09:03 UTC

This package is auto-updated.

Last update: 2024-10-29 12:33:58 UTC


README

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