Events | laravel-backup | Spatie

 SPATIE

  Laravel Backup
=================

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Laravel-backup](https://spatie.be/docs/laravel-backup/v4)  Cleaning-up-old-backups  Events

 Version   v10   v9   v8   v7   v6   v5   v4   v3

 Other versions for crawler [v10](https://spatie.be/docs/laravel-backup/v10) [v9](https://spatie.be/docs/laravel-backup/v9) [v8](https://spatie.be/docs/laravel-backup/v8) [v7](https://spatie.be/docs/laravel-backup/v7) [v6](https://spatie.be/docs/laravel-backup/v6) [v5](https://spatie.be/docs/laravel-backup/v5) [v4](https://spatie.be/docs/laravel-backup/v4) [v3](https://spatie.be/docs/laravel-backup/v3)

- [ Introduction ](https://spatie.be/docs/laravel-backup/v4/introduction)
- [ Postcardware ](https://spatie.be/docs/laravel-backup/v4/postcardware)
- [ Requirements ](https://spatie.be/docs/laravel-backup/v4/requirements)
- [ High level overview ](https://spatie.be/docs/laravel-backup/v4/high-level-overview)
- [ Installation and setup ](https://spatie.be/docs/laravel-backup/v4/installation-and-setup)
- [ Questions &amp; issues ](https://spatie.be/docs/laravel-backup/v4/questions-and-issues)
- [ Changelog ](https://spatie.be/docs/laravel-backup/v4/changelog)
- [ About us ](https://spatie.be/docs/laravel-backup/v4/about-us)

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

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

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

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

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

- [ Events ](https://spatie.be/docs/laravel-backup/v4/monitoring-the-health-of-all-backups/events)
- [ Monitoring the health of all backups ](https://spatie.be/docs/laravel-backup/v4/monitoring-the-health-of-all-backups/overview)

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

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

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

- [ Adding extra files to a backup ](https://spatie.be/docs/laravel-backup/v4/advanced-usage/adding-extra-files-to-a-backup)
- [ Backing up a non-laravel application ](https://spatie.be/docs/laravel-backup/v4/advanced-usage/backing-up-a-non-laravel-application)

      You are viewing the documentation for **an older version** of this package. You can check the version you are using with the following command:

 `                                    composer show spatie/laravel-backup                                                                                                                                                                                                                                    `

Events
======

###  On this page

1. [ CleanupWasSuccessful ](#content-cleanupwassuccessful)
2. [ CleanupHasFailed ](#content-cleanuphasfailed)

These events are fired during the cleanup process.

CleanupWasSuccessful
--------------------------------------------------------------------------------------------------------------------

`Spatie\Backup\Events\CleanupWasSuccessful`

This event is fired when old backups are successfully removed from a destination filesystem.

It has one public property `$backupDestination` that contains an instance of `Spatie\Backup\BackupDestination\BackupDestination`.

CleanupHasFailed
--------------------------------------------------------------------------------------------------------

`Spatie\Backup\Events\CleanupHasFailed`

This event is fired when something goes wrong while cleaning up.

It has two public properties:

- `$exception`: an object that conforms to the `Exception` interface. It is highly likely that `$exception->getMessage()` will return more information on what went wrong.
- `$backupDestination`: if this is `null` then something probably went wrong before even connecting to one of the backup destinations. If it is an instance of `Spatie\Backup\BackupDestination\BackupDestination` something went wrong when trying to connect or write to that destination.
