Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for checking backups on filesystem disks #237

Merged

Conversation

pelmered
Copy link
Contributor

This adds support for checking backups on any filesystem you have defined in your Laravel installation. Including for example an S3 bucket.

The syntax is very simple. Something like this works with spatie/laravel-backup when backups are saved to S3:

            BackupsCheck::new()
                        ->onDisk('backups_remote')
                        ->locatedAt(config('backup.backup.name'))

I needed to create a new file BackupFile.php to abstract away the filesystem from SymfonyFile that you used before. This was the best solution to make this backwards compatible and support the glob style syntax in ->locatedAt(). When using Filesystem disk glob is not available and therefore that is not supported when using a Laravel disk.

In the next major version I would suggest to stop using SymfonyFile and only use the Laravel FIlesystem. I think that is probably the right way to do this. With the filter option below, we can restore all current functionality.

Questions:

  1. Should we look for files recursively in the folder passed in with locatedAt?
  2. As this removes the glob supper, do we need to let the user filter the files? For example with a callback? I don't need that in my use case, but I can see that others would need that. For example: ->filterFilesUsing(fn ($path) => preg_match('/backup\/[0-9-]+\.zip/', $path). I can add that if you think it is a good idea.

I can also update the docs if you want.

@freekmurze freekmurze merged commit dfd3e6e into spatie:main Jul 22, 2024
11 checks passed
@freekmurze
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants