Skip to content

Commit 30cf0c6

Browse files
Added support for spatie/laravel-backup v9 and drop support for v8 and 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]>
1 parent 15e156c commit 30cf0c6

File tree

6 files changed

+80
-9
lines changed

6 files changed

+80
-9
lines changed

.github/workflows/run-tests.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
fail-fast: false
1414
matrix:
1515
os: [ubuntu-latest]
16-
php: [8.3, 8.2, 8.1]
16+
php: [8.3, 8.2]
1717
laravel: ['10.*', '11.*']
1818
stability: [prefer-lowest, prefer-stable]
1919
include:
@@ -23,9 +23,6 @@ jobs:
2323
- laravel: 11.*
2424
testbench: ^9.0
2525
carbon: ^2.63
26-
exclude:
27-
- laravel: 11.*
28-
php: 8.1
2926

3027
services:
3128
mysql:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ phpstan.neon
99
vendor
1010
node_modules
1111
database/database.sqlite
12+
.DS_Store

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

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

10-
The package requires Laravel v10.17 or higher and PHP 8.1 or higher.
10+
The package requires Laravel v10.17 or higher and PHP 8.2 or higher.
1111

1212
## Installation
1313

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
}
1717
],
1818
"require": {
19-
"php": "^8.1",
19+
"php": "^8.2",
2020
"ext-zip": "*",
2121
"illuminate/contracts": "^10.17.0 || ^11.0",
2222
"laravel/prompts": "^0.1.11",
23-
"spatie/laravel-backup": "^8.0",
23+
"spatie/laravel-backup": "^9.0",
2424
"spatie/laravel-package-tools": "^1.14.0",
2525
"spatie/temporary-directory": "^2.0"
2626
},

src/Commands/RestoreCommand.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,11 @@ public function handle(
6868
// Dependencies-check is currently disabled. Custom binary paths are currently not supported by the Action.
6969
// $checkDependenciesAction->execute($connection);
7070

71+
$diskToRestoreFrom = $this->getDestinationDiskToRestoreFrom();
72+
7173
$pendingRestore = PendingRestore::make(
72-
disk: $this->getDestinationDiskToRestoreFrom(),
73-
backup: $this->getBackupToRestore($this->getDestinationDiskToRestoreFrom()),
74+
disk: $diskToRestoreFrom,
75+
backup: $this->getBackupToRestore($diskToRestoreFrom),
7476
connection: $connection,
7577
backupPassword: $this->getPassword(),
7678
);

workbench/app/BackupRestoreWorkbenchProvider.php

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Workbench\App;
66

77
use Illuminate\Support\ServiceProvider;
8+
use ZipArchive;
89

910
class BackupRestoreWorkbenchProvider extends ServiceProvider
1011
{
@@ -73,14 +74,30 @@ public function boot()
7374
'backup' => [
7475
'name' => env('APP_NAME', 'Laravel'),
7576
'source' => [
77+
'files' => [
78+
'include' => [
79+
base_path(),
80+
],
81+
'exclude' => [
82+
base_path('vendor'),
83+
base_path('node_modules'),
84+
],
85+
'follow_links' => false,
86+
'ignore_unreadable_directories' => false,
87+
'relative_path' => null,
88+
],
7689
'databases' => [
7790
'mysql',
7891
],
7992
],
8093
'database_dump_compressor' => \Spatie\DbDumper\Compressors\GzipCompressor::class,
94+
'database_dump_file_timestamp_format' => null,
95+
'database_dump_filename_base' => 'database',
8196
'database_dump_file_extension' => '',
8297

8398
'destination' => [
99+
'compression_method' => ZipArchive::CM_DEFAULT,
100+
'compression_level' => 9,
84101
'filename_prefix' => '',
85102
'disks' => [
86103
'remote',
@@ -89,6 +106,60 @@ public function boot()
89106
'temporary_directory' => storage_path('app/backup-temp'),
90107
'password' => env('BACKUP_ARCHIVE_PASSWORD'),
91108
'encryption' => 'default',
109+
'tries' => 1,
110+
'retry_delay' => 0,
111+
],
112+
'notifications' => [
113+
'notifications' => [
114+
\Spatie\Backup\Notifications\Notifications\BackupHasFailedNotification::class => ['mail'],
115+
\Spatie\Backup\Notifications\Notifications\UnhealthyBackupWasFoundNotification::class => ['mail'],
116+
\Spatie\Backup\Notifications\Notifications\CleanupHasFailedNotification::class => ['mail'],
117+
\Spatie\Backup\Notifications\Notifications\BackupWasSuccessfulNotification::class => ['mail'],
118+
\Spatie\Backup\Notifications\Notifications\HealthyBackupWasFoundNotification::class => ['mail'],
119+
\Spatie\Backup\Notifications\Notifications\CleanupWasSuccessfulNotification::class => ['mail'],
120+
],
121+
'notifiable' => \Spatie\Backup\Notifications\Notifiable::class,
122+
'mail' => [
123+
'to' => '[email protected]',
124+
'from' => [
125+
'address' => env('MAIL_FROM_ADDRESS', '[email protected]'),
126+
'name' => env('MAIL_FROM_NAME', 'Example'),
127+
],
128+
],
129+
'slack' => [
130+
'webhook_url' => '',
131+
'channel' => null,
132+
'username' => null,
133+
'icon' => null,
134+
],
135+
'discord' => [
136+
'webhook_url' => '',
137+
'username' => '',
138+
'avatar_url' => '',
139+
],
140+
],
141+
'monitor_backups' => [
142+
[
143+
'name' => env('APP_NAME', 'laravel-backup'),
144+
'disks' => ['local'],
145+
'health_checks' => [
146+
\Spatie\Backup\Tasks\Monitor\HealthChecks\MaximumAgeInDays::class => 1,
147+
\Spatie\Backup\Tasks\Monitor\HealthChecks\MaximumStorageInMegabytes::class => 5000,
148+
],
149+
],
150+
],
151+
'cleanup' => [
152+
'strategy' => \Spatie\Backup\Tasks\Cleanup\Strategies\DefaultStrategy::class,
153+
'default_strategy' => [
154+
'keep_all_backups_for_days' => 7,
155+
'keep_daily_backups_for_days' => 16,
156+
'keep_weekly_backups_for_weeks' => 8,
157+
'keep_monthly_backups_for_months' => 4,
158+
'keep_yearly_backups_for_years' => 2,
159+
'delete_oldest_backups_when_using_more_megabytes_than' => 5000,
160+
],
161+
'tries' => 1,
162+
'retry_delay' => 0,
92163
],
93164
]);
94165
}

0 commit comments

Comments
 (0)