You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(backup)!: add support for customizing backup names and use ids to identify backups (#60)
Refactors backup naming and retrieval to allow users to implement custom `BackupNameResolver`s.
BREAKING CHANGE: backups using the old system wont be discovered anymore.
uploading files is also reworked so they will now appear in the list and get ran through the namegenerator.
If you want to customize how backups are named and "discovered", you can!
4
+
5
+
The default naming scheme will be:
6
+
7
+
```
8
+
{app.name}-{timestamp}-{id}.zip
9
+
```
10
+
11
+
## Customizing
12
+
13
+
You can customize the naming by providing your own `BackupNameResolver` implementation.
14
+
15
+
This class is responsible for generating filenames and parsing files into identifiable information and required metadata in the form of `ResolvedBackupData`.
16
+
So when making your own implementation, you need to make sure that your generate and parseFilename methods work togheter or it will not work.
17
+
18
+
Here is an example of a custom `BackupNameResolver` implementation:
19
+
20
+
```php
21
+
use Carbon\CarbonImmutable;
22
+
use Itiden\Backup\Contracts\BackupNameResolver;
23
+
use Itiden\Backup\DataTransferObjects\ResolvedBackupData;
24
+
25
+
final readonly class MyAppSpecificBackupNameResolver implements BackupNameResolver
26
+
{
27
+
private const string Separator = '---';
28
+
29
+
// return a custom filename, the ".zip" extension will be added automatically if it is missing
30
+
public function generateFilename(CarbonImmutable $createdAt, string $id): string
31
+
{
32
+
$parts = [
33
+
"some-testest-that-implies-something",
34
+
$createdAt->format('Y-m-d'),
35
+
$id,
36
+
];
37
+
38
+
return implode(self::Separator, $parts);
39
+
}
40
+
41
+
public function parseFilename(string $path): ?ResolvedBackupData
0 commit comments