PHP code example of bhavgoyal99 / laravel-smart-backup

1. Go to this page and download the library: Download bhavgoyal99/laravel-smart-backup library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bhavgoyal99 / laravel-smart-backup example snippets


return [
    'mode' => 'full',
    'format' => 'sql',
    'chunk_size' => 1000,

    'tables' => [
        'ocal',
        'path' => 'backups/database',
    ],
];

'schedule' => [
    'enabled' => true,
    'frequency' => 'daily',
    'time' => '02:00',
    'timezone' => 'Asia/Kolkata',
],

'maintenance' => [
    'enabled' => true,
],

'ui' => [
    'enabled' => true,
    'prefix' => 'smart-backup',
    'middleware' => explode(',', env('SMART_BACKUP_UI_MIDDLEWARE', 'web,auth')),
    'name_prefix' => env('SMART_BACKUP_UI_NAME_PREFIX', 'smart-backup.'),
],

'ui' => [
    'dispatch_after_response' => false,
],
bash
php artisan vendor:publish --tag=smart-backup-config
php artisan vendor:publish --tag=smart-backup-migrations
php artisan vendor:publish --tag=smart-backup-views
bash
php artisan migrate
bash
php artisan backup:run
bash
php artisan backup:run --mode=incremental --format=json --tables=users --tables=orders
bash
php artisan backup:restore backups/database/full/2026/04/07/users-20260407_010000.sql
bash
php artisan backup:restore backups/database/full/2026/04/07/users-20260407_010000.sql --table=users
bash
php artisan backup:restore backups/database/full/2026/04/07/users-20260407_010000.sql --password=secret