Events | laravel-backup-rust | Spatie       

 SPATIE  

laravel-backup-rust
===================

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Laravel-backup-rust](https://spatie.be/docs/laravel-backup-rust/v1)  Taking-backups  Events

 Version   v1      

 Other versions for crawler [v1](https://spatie.be/docs/laravel-backup-rust/v1) 

  Events    
- [ Introduction ](https://spatie.be/docs/laravel-backup-rust/v1/introduction)
- [ Support us ](https://spatie.be/docs/laravel-backup-rust/v1/support-us)
- [ Requirements ](https://spatie.be/docs/laravel-backup-rust/v1/requirements)
- [ High level overview ](https://spatie.be/docs/laravel-backup-rust/v1/high-level-overview)
- [ Installation and setup ](https://spatie.be/docs/laravel-backup-rust/v1/installation-and-setup)
- [ Questions &amp; issues ](https://spatie.be/docs/laravel-backup-rust/v1/questions-and-issues)
- [ Changelog ](https://spatie.be/docs/laravel-backup-rust/v1/changelog)
- [ About us ](https://spatie.be/docs/laravel-backup-rust/v1/about-us)
- [ Testing ](https://spatie.be/docs/laravel-backup-rust/v1/testing)

Taking Backups
--------------

- [ Taking backups ](https://spatie.be/docs/laravel-backup-rust/v1/taking-backups/overview)
- [ Events ](https://spatie.be/docs/laravel-backup-rust/v1/taking-backups/events)

Cleaning up old backups
-----------------------

- [ Cleaning up old backups ](https://spatie.be/docs/laravel-backup-rust/v1/cleaning-up-old-backups/overview)
- [ Events ](https://spatie.be/docs/laravel-backup-rust/v1/cleaning-up-old-backups/events)

Monitoring the health of all backups
------------------------------------

- [ Monitoring the health of all backups ](https://spatie.be/docs/laravel-backup-rust/v1/monitoring-the-health-of-all-backups/overview)
- [ Creating your custom health check ](https://spatie.be/docs/laravel-backup-rust/v1/monitoring-the-health-of-all-backups/creating-your-custom-health-check)
- [ Events ](https://spatie.be/docs/laravel-backup-rust/v1/monitoring-the-health-of-all-backups/events)

Sending notifications
---------------------

- [ Sending notifications ](https://spatie.be/docs/laravel-backup-rust/v1/sending-notifications/overview)
- [ Adding extra notification channels ](https://spatie.be/docs/laravel-backup-rust/v1/sending-notifications/adding-extra-notification-channels)
- [ Customizing the notifiable ](https://spatie.be/docs/laravel-backup-rust/v1/sending-notifications/customizing-the-notifiable)

Advanced Usage
--------------

- [ Adding extra files to a backup ](https://spatie.be/docs/laravel-backup-rust/v1/advanced-usage/adding-extra-files-to-a-backup)
- [ Backing up a non-laravel application ](https://spatie.be/docs/laravel-backup-rust/v1/advanced-usage/backing-up-a-non-laravel-application)
- [ Binary database dumps with PostgreSQL ](https://spatie.be/docs/laravel-backup-rust/v1/advanced-usage/binary-database-dumps-with-postgresql)
- [ Encrypt backup archives ](https://spatie.be/docs/laravel-backup-rust/v1/advanced-usage/encrypt-backup-archives)
- [ Isolated mode ](https://spatie.be/docs/laravel-backup-rust/v1/advanced-usage/isolated-mode)

 Events
======

###  On this page 

1. [ BackupWasSuccessful ](#content-backupwassuccessful)
2. [ BackupHasFailed ](#content-backuphasfailed)
3. [ BackupManifestWasCreated ](#content-backupmanifestwascreated)
4. [ BackupZipWasCreated ](#content-backupzipwascreated)
5. [ DumpingDatabase ](#content-dumpingdatabase)

- Subscribe to types in `spatie_backup::events` with Laravel's event dispatcher.
- The `notifications::Event` envelope is also dispatched for listeners that handle all event kinds.
- Events observe job state. Use `Lifecycle` hooks to modify a dumper, manifest or ZIP before publication.

```
use spatie_backup::events::BackupWasSuccessful;

let app = laravel::Application::configure()
    .with_providers(|providers| { providers.add(spatie_backup::service_provider()); })
    .with_events(|events, _| {
        events.listen(|event: laravel::event::Event<BackupWasSuccessful>| async move {
            tracing::info!(disk = %event.disk_name, backup = %event.backup_name, "Backup stored");
        });
    })
    .create();
```

BackupWasSuccessful
-----------------------------------------------------------------------------------------------------------------

- Fired once for each destination that accepts the archive.
- `disk_name` and `backup_name` identify the disk and logical backup directory.
- `backup_summary` contains a fresh inventory summary, or an `error` field if the inventory cannot be read.

BackupHasFailed
-----------------------------------------------------------------------------------------------------

- Fired after a failed backup exhausts its retries, or immediately for a failed disk when `continue_on_failure` is enabled.
- `error` describes the failure.
- `disk_name` and `backup_name` are optional when the failure cannot be attributed to a destination.

BackupManifestWasCreated
--------------------------------------------------------------------------------------------------------------------------------

- Fired after source selection, database dumps and the mutable manifest hook.
- `files` contains paths to the selected files, directories and generated dumps.
- Use `Lifecycle::manifest_was_created` to [add files](../advanced-usage/adding-extra-files-to-a-backup).

BackupZipWasCreated
-----------------------------------------------------------------------------------------------------------------

- Fired after ZIP creation and the mutable ZIP hook, before verification and publication.
- `path` identifies the temporary ZIP and is valid until the job returns.
- Use `Lifecycle::zip_was_created` to modify the ZIP.

DumpingDatabase
-----------------------------------------------------------------------------------------------------

- Fired after the mutable dumper hook, before native dump execution.
- `connection` and `database` identify the selected Laravel connection and database.
- Use `Lifecycle::dumping_database` to change native dump options.

 A good
match?
-------------

### What we do best

- All things Laravel
- Custom frontend components
- Building APIs
- AI-powered features
- Simplifying things
- Clean solutions
- Integrating services

### Not our cup of tea

- WordPress themes
- Cutting corners
- Free mockups to win a job
- "Just execute the briefing"

 In short: we'd like to be a **substantial part** of your project.

 [ Get in touch via email ](mailto:info@spatie.be?subject=A%20good%20match%21&body=Tell%20us%20as%20much%20as%20you%20can%20about%0A-%20your%20online%20project%0A-%20your%20planning%0A-%20your%20budget%0A-%20%E2%80%A6%0A%0AAnything%20that%20helps%20us%20to%20start%20straightforward%21)
