Skip to content

Commit

Permalink
Added support for spatie/laravel-backup v9 and drop support for v8 an…
Browse files Browse the repository at this point in the history
…d PHP 8.1 (#76)

* Added support for spatie/laravel-backup version 9

This required all config settings to be present as described in the [upgrade guide](https://github.com/spatie/laravel-backup/blob/main/UPGRADING.md)

* Updated the .gitignore file

* The restore no longer asks twice for the disk to restore from

* Removed the tests for PHP 8.1 as it is no longer supported by Spatie Laravel Backup

* Update PHP Requirements in README

* Drop Support for spatie/laravel-backup v8

---------

Co-authored-by: Stefan Zweifel <[email protected]>
  • Loading branch information
pieterclaerhout and stefanzweifel authored Aug 7, 2024
1 parent 15e156c commit 30cf0c6
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 9 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
php: [8.3, 8.2, 8.1]
php: [8.3, 8.2]
laravel: ['10.*', '11.*']
stability: [prefer-lowest, prefer-stable]
include:
Expand All @@ -23,9 +23,6 @@ jobs:
- laravel: 11.*
testbench: ^9.0
carbon: ^2.63
exclude:
- laravel: 11.*
php: 8.1

services:
mysql:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ phpstan.neon
vendor
node_modules
database/database.sqlite
.DS_Store
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

A package to restore a database backup created by the [spatie/laravel-backup](https://github.com/spatie/laravel-backup) package.

The package requires Laravel v10.17 or higher and PHP 8.1 or higher.
The package requires Laravel v10.17 or higher and PHP 8.2 or higher.

## Installation

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
}
],
"require": {
"php": "^8.1",
"php": "^8.2",
"ext-zip": "*",
"illuminate/contracts": "^10.17.0 || ^11.0",
"laravel/prompts": "^0.1.11",
"spatie/laravel-backup": "^8.0",
"spatie/laravel-backup": "^9.0",
"spatie/laravel-package-tools": "^1.14.0",
"spatie/temporary-directory": "^2.0"
},
Expand Down
6 changes: 4 additions & 2 deletions src/Commands/RestoreCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,11 @@ public function handle(
// Dependencies-check is currently disabled. Custom binary paths are currently not supported by the Action.
// $checkDependenciesAction->execute($connection);

$diskToRestoreFrom = $this->getDestinationDiskToRestoreFrom();

$pendingRestore = PendingRestore::make(
disk: $this->getDestinationDiskToRestoreFrom(),
backup: $this->getBackupToRestore($this->getDestinationDiskToRestoreFrom()),
disk: $diskToRestoreFrom,
backup: $this->getBackupToRestore($diskToRestoreFrom),
connection: $connection,
backupPassword: $this->getPassword(),
);
Expand Down
71 changes: 71 additions & 0 deletions workbench/app/BackupRestoreWorkbenchProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Workbench\App;

use Illuminate\Support\ServiceProvider;
use ZipArchive;

class BackupRestoreWorkbenchProvider extends ServiceProvider
{
Expand Down Expand Up @@ -73,14 +74,30 @@ public function boot()
'backup' => [
'name' => env('APP_NAME', 'Laravel'),
'source' => [
'files' => [
'include' => [
base_path(),
],
'exclude' => [
base_path('vendor'),
base_path('node_modules'),
],
'follow_links' => false,
'ignore_unreadable_directories' => false,
'relative_path' => null,
],
'databases' => [
'mysql',
],
],
'database_dump_compressor' => \Spatie\DbDumper\Compressors\GzipCompressor::class,
'database_dump_file_timestamp_format' => null,
'database_dump_filename_base' => 'database',
'database_dump_file_extension' => '',

'destination' => [
'compression_method' => ZipArchive::CM_DEFAULT,
'compression_level' => 9,
'filename_prefix' => '',
'disks' => [
'remote',
Expand All @@ -89,6 +106,60 @@ public function boot()
'temporary_directory' => storage_path('app/backup-temp'),
'password' => env('BACKUP_ARCHIVE_PASSWORD'),
'encryption' => 'default',
'tries' => 1,
'retry_delay' => 0,
],
'notifications' => [
'notifications' => [
\Spatie\Backup\Notifications\Notifications\BackupHasFailedNotification::class => ['mail'],
\Spatie\Backup\Notifications\Notifications\UnhealthyBackupWasFoundNotification::class => ['mail'],
\Spatie\Backup\Notifications\Notifications\CleanupHasFailedNotification::class => ['mail'],
\Spatie\Backup\Notifications\Notifications\BackupWasSuccessfulNotification::class => ['mail'],
\Spatie\Backup\Notifications\Notifications\HealthyBackupWasFoundNotification::class => ['mail'],
\Spatie\Backup\Notifications\Notifications\CleanupWasSuccessfulNotification::class => ['mail'],
],
'notifiable' => \Spatie\Backup\Notifications\Notifiable::class,
'mail' => [
'to' => '[email protected]',
'from' => [
'address' => env('MAIL_FROM_ADDRESS', '[email protected]'),
'name' => env('MAIL_FROM_NAME', 'Example'),
],
],
'slack' => [
'webhook_url' => '',
'channel' => null,
'username' => null,
'icon' => null,
],
'discord' => [
'webhook_url' => '',
'username' => '',
'avatar_url' => '',
],
],
'monitor_backups' => [
[
'name' => env('APP_NAME', 'laravel-backup'),
'disks' => ['local'],
'health_checks' => [
\Spatie\Backup\Tasks\Monitor\HealthChecks\MaximumAgeInDays::class => 1,
\Spatie\Backup\Tasks\Monitor\HealthChecks\MaximumStorageInMegabytes::class => 5000,
],
],
],
'cleanup' => [
'strategy' => \Spatie\Backup\Tasks\Cleanup\Strategies\DefaultStrategy::class,
'default_strategy' => [
'keep_all_backups_for_days' => 7,
'keep_daily_backups_for_days' => 16,
'keep_weekly_backups_for_weeks' => 8,
'keep_monthly_backups_for_months' => 4,
'keep_yearly_backups_for_years' => 2,
'delete_oldest_backups_when_using_more_megabytes_than' => 5000,
],
'tries' => 1,
'retry_delay' => 0,
],
]);
}
Expand Down

0 comments on commit 30cf0c6

Please sign in to comment.