oriondevelops/filament-backup

A Filament plugin to backup your app.

v1.0.2 2023-10-02 02:51 UTC

This package is auto-updated.

Last update: 2024-10-18 08:53:17 UTC


README

Latest Version on Packagist Total Downloads

This Filament plugin is a dedicated port of the spatie/nova-backup-tool, adapted to work seamlessly with Filament.

Much of the underlying codebase and functionality owe their origins to the work done by the contributors on the original Nova tool. This adaptation was undertaken with deep respect and acknowledgment of their effort.

The plugin lets you:

  • List all backups
  • Create a new backup
  • Download a backup
  • Delete a backup

Internally, it utilizes spatie/laravel-backup to manage these backups.

screenshot

Requirements

Ensure that you meet the requirements for spatie/laravel-backup.

Installation

Install spatie/laravel-backup into your Laravel app following its installation instructions.

You can install the package via composer:

composer require oriondevelops/filament-backup

Next you should setup a queue. Any driver is fine except the sync driver.

Usage

You need to register the plugin with your preferred Filament panel providers. This can be done inside of your PanelProvider, e.g. AdminPanelProvider.

<?php

namespace App\Providers\Filament;

use Filament\Panel;
use Filament\PanelProvider;
use Orion\FilamentBackup\BackupPlugin;

class AdminPanelProvider extends PanelProvider
{
    public function panel(Panel $panel): Panel
    {
        return $panel
            // ...
            ->plugin(BackupPlugin::make());
    }
}

You can now click on the "Backups" menu item in your Filament app to see the backup plugin.

Customizing visibility, download and delete permissions

Define who can view, download, or delete backups. Tailor access based on user permissions.

<?php

namespace App\Providers\Filament;

use Filament\Panel;
use Filament\PanelProvider;
use Orion\FilamentBackup\BackupPlugin;

class AdminPanelProvider extends PanelProvider
{
    public function panel(Panel $panel): Panel
    {
        return $panel
            // ...
            ->plugin(
                BackupPlugin::make()
                    ->visible(fn() => auth()->user()->can('view backups'))
                    ->downloadable(fn() => auth()->user()->can('download backups'))
                    ->deletable(fn() => auth()->user()->can('delete backups')),
            );
    }
}

Customizing the navigation item

<?php

namespace App\Providers\Filament;

use Filament\Panel;
use Filament\PanelProvider;
use Orion\FilamentBackup\BackupPlugin;

class AdminPanelProvider extends PanelProvider
{
    public function panel(Panel $panel): Panel
    {
        return $panel
            // ...
            ->plugin(
                BackupPlugin::make()
                    ->slug('my-precious-backups')
                    ->label('Backups')
                    ->icon('heroicon-o-server-stack')
                    ->group('System')
                    ->sort(3),
            );
    }
}

Customizing the polling interval

You can customise the polling interval or disable polling:

<?php

namespace App\Providers\Filament;

use Filament\Panel;
use Filament\PanelProvider;
use Orion\FilamentBackup\BackupPlugin;

class AdminPanelProvider extends PanelProvider
{
    public function panel(Panel $panel): Panel
    {
        return $panel
            // ...
            ->plugin(
                BackupPlugin::make()
                    ->polling(enabled: true, interval: '10s'),
            );
    }
}

Customizing the backup queue and page

<?php

namespace App\Providers\Filament;

use Filament\Panel;
use Filament\PanelProvider;
use Orion\FilamentBackup\BackupPlugin;
use App\Filament\Pages\ExtendedBackupsPage;

class AdminPanelProvider extends PanelProvider
{
    public function panel(Panel $panel): Panel
    {
        return $panel
            // ...
            ->plugin(
                BackupPlugin::make()
                    ->queue('custom-queue')
                    ->page(ExtendedBackupsPage::class),
            );
    }
}

Contributing

Please see CONTRIBUTING for details.

Security

Please review Security Policy on how to report security vulnerabilities.

Nova Backup Tool Credits

Credits

License

The MIT License (MIT). Please see License File for more information.