From 78112fe28854caa7bfe6155b1cadcb9756f508db Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Thu, 27 Feb 2020 16:42:57 +0100 Subject: [PATCH] wip #3439 @0.25 --- .../Controllers/Admin/QuizCrudController.php | 16 ++ composer.lock | 20 +- config/backup.php | 202 ++++++++++++++++++ config/filesystems.php | 10 + routes/backpack/custom.php | 10 +- 5 files changed, 240 insertions(+), 18 deletions(-) create mode 100644 app/Http/Controllers/Admin/QuizCrudController.php create mode 100644 config/backup.php diff --git a/app/Http/Controllers/Admin/QuizCrudController.php b/app/Http/Controllers/Admin/QuizCrudController.php new file mode 100644 index 0000000..5048ce6 --- /dev/null +++ b/app/Http/Controllers/Admin/QuizCrudController.php @@ -0,0 +1,16 @@ + [ + + /* -------------------------------------- + * Backpack\BackupManager Command Flags + * -------------------------------------- + * These flags will be attached every time a backup is triggered + * by Backpack\BackupManager. By default only notifications are disabled. + * + * https://docs.spatie.be/laravel-backup/v4/taking-backups/overview + * --only-to-disk=name-of-your-disk + * --only-db + * --only-files + * --disable-notifications + */ + 'backpack_flags' => [ + '--disable-notifications'=> true, + ], + + /* + * The name of this application. You can use this name to monitor + * the backups. + */ + 'name' => env('APP_URL'), + + 'source' => [ + + 'files' => [ + + /* + * The list of directories that should be part of the backup. You can + * specify individual files as well. + */ + 'include' => [ + base_path(), + ], + + /* + * These directories will be excluded from the backup. + * You can specify individual files as well. + */ + 'exclude' => [ + base_path('vendor'), + storage_path(), + ], + + /* + * Determines if symlinks should be followed. + */ + 'followLinks' => false, + ], + + /* + * The names of the connections to the databases that should be part of the backup. + * Currently only MySQL- and PostgreSQL-databases are supported. + */ + 'databases' => [ + 'mysql', + ], + ], + + /* + * The database dump can be gzipped to decrease diskspace usage. + */ + 'gzip_database_dump' => false, + + 'destination' => [ + + /* + * The filename prefix used for the backup zip file. + */ + 'filename_prefix' => '', + + /* + * The disk names on which the backups will be stored. + */ + 'disks' => [ + 'backups', + ], + ], + + 'temporary_directory' => storage_path('app/backup-temp'), + ], + + /* + * You can get notified when specific events occur. Out of the box you can use 'mail' and 'slack'. + * For Slack you need to install guzzlehttp/guzzle. + * + * You can also use your own notification classes, just make sure the class is named after one of + * the `Spatie\Backup\Events` classes. + */ + 'notifications' => [ + + 'notifications' => [ + \Spatie\Backup\Notifications\Notifications\BackupHasFailed::class => ['mail'], + \Spatie\Backup\Notifications\Notifications\UnhealthyBackupWasFound::class => ['mail'], + \Spatie\Backup\Notifications\Notifications\CleanupHasFailed::class => ['mail'], + \Spatie\Backup\Notifications\Notifications\BackupWasSuccessful::class => ['mail'], + \Spatie\Backup\Notifications\Notifications\HealthyBackupWasFound::class => ['mail'], + \Spatie\Backup\Notifications\Notifications\CleanupWasSuccessful::class => ['mail'], + ], + + /* + * Here you can specify the notifiable to which the notifications should be sent. The default + * notifiable will use the variables specified in this config file. + */ + 'notifiable' => \Spatie\Backup\Notifications\Notifiable::class, + + /* + * Here you can specify how emails should be sent. + */ + 'mail' => [ + 'to' => 'your@email.com', + ], + + /* + * Here you can specify how messages should be sent to Slack. + */ + 'slack' => [ + 'webhook_url' => '', + + /* + * If this is set to null the default channel of the webhook will be used. + */ + 'channel' => null, + ], + ], + + /* + * Here you can specify which backups should be monitored. + * If a backup does not meet the specified requirements the + * UnHealthyBackupWasFound event will be fired. + */ + 'monitorBackups' => [ + [ + 'name' => env('APP_NAME'), + 'disks' => ['backups'], + 'newestBackupsShouldNotBeOlderThanDays' => 1, + 'storageUsedMayNotBeHigherThanMegabytes' => 5000, + ], + + /* + [ + 'name' => 'name of the second app', + 'disks' => ['local', 's3'], + 'newestBackupsShouldNotBeOlderThanDays' => 1, + 'storageUsedMayNotBeHigherThanMegabytes' => 5000, + ], + */ + ], + + 'cleanup' => [ + /* + * The strategy that will be used to cleanup old backups. The default strategy + * will keep all backups for a certain amount of days. After that period only + * a daily backup will be kept. After that period only weekly backups will + * be kept and so on. + * + * No matter how you configure it the default strategy will never + * delete the newest backup. + */ + 'strategy' => \Spatie\Backup\Tasks\Cleanup\Strategies\DefaultStrategy::class, + + 'defaultStrategy' => [ + + /* + * The number of days for which backups must be kept. + */ + 'keepAllBackupsForDays' => 7, + + /* + * The number of days for which daily backups must be kept. + */ + 'keepDailyBackupsForDays' => 16, + + /* + * The number of weeks for which one weekly backup must be kept. + */ + 'keepWeeklyBackupsForWeeks' => 8, + + /* + * The number of months for which one monthly backup must be kept. + */ + 'keepMonthlyBackupsForMonths' => 4, + + /* + * The number of years for which one yearly backup must be kept. + */ + 'keepYearlyBackupsForYears' => 2, + + /* + * After cleaning up the backups remove the oldest backup until + * this amount of megabytes has been reached. + */ + 'deleteOldestBackupsWhenUsingMoreMegabytesThan' => 5000, + ], + ], + +]; diff --git a/config/filesystems.php b/config/filesystems.php index ec6a7ce..792ff1a 100644 --- a/config/filesystems.php +++ b/config/filesystems.php @@ -64,6 +64,16 @@ return [ 'url' => env('AWS_URL'), ], + // used for Backpack/BackupManager + 'backups' => [ + 'driver' => 'local', + 'root' => storage_path('backups'), // that's where your backups are stored by default: storage/backups + ], + + 'storage' => [ + 'driver' => 'local', + 'root' => storage_path(), + ], ], ]; diff --git a/routes/backpack/custom.php b/routes/backpack/custom.php index 85e8c97..c2f7f55 100644 --- a/routes/backpack/custom.php +++ b/routes/backpack/custom.php @@ -1,14 +1,8 @@ config('backpack.base.route_prefix', 'admin'), 'middleware' => ['web', config('backpack.base.middleware_key', 'admin')], 'namespace' => 'App\Http\Controllers\Admin', ], function () { // custom admin routes -}); // this should be the absolute last line of this file + +}); -- 2.39.5