Events | laravel-backup | Spatie

 SPATIE

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

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Laravel-backup](https://spatie.be/docs/laravel-backup/v10)  Taking-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/v10/introduction)
- [ Support us ](https://spatie.be/docs/laravel-backup/v10/support-us)
- [ Requirements ](https://spatie.be/docs/laravel-backup/v10/requirements)
- [ High level overview ](https://spatie.be/docs/laravel-backup/v10/high-level-overview)
- [ Installation and setup ](https://spatie.be/docs/laravel-backup/v10/installation-and-setup)
- [ Questions &amp; issues ](https://spatie.be/docs/laravel-backup/v10/questions-and-issues)
- [ Changelog ](https://spatie.be/docs/laravel-backup/v10/changelog)
- [ About us ](https://spatie.be/docs/laravel-backup/v10/about-us)

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

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

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

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

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

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

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

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

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

- [ Adding extra files to a backup ](https://spatie.be/docs/laravel-backup/v10/advanced-usage/adding-extra-files-to-a-backup)
- [ Backing up a non-laravel application ](https://spatie.be/docs/laravel-backup/v10/advanced-usage/backing-up-a-non-laravel-application)
- [ Binary database dumps with PostgreSQL ](https://spatie.be/docs/laravel-backup/v10/advanced-usage/binary-database-dumps-with-postgresql)
- [ Encrypt backup archives ](https://spatie.be/docs/laravel-backup/v10/advanced-usage/encrypt-backup-archives)
- [ Isolated mode ](https://spatie.be/docs/laravel-backup/v10/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)

These events are fired during the backup process.

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

`Spatie\Backup\Events\BackupWasSuccessful`

This event is fired when the zip file containing all files that should be backed up has successfully been copied to a destination filesystem.

It has two public properties:

- `$diskName`: a string containing the name of the destination disk.
- `$backupName`: a string containing the name of the backup.

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

`Spatie\Backup\Events\BackupHasFailed`

This event will be fired when something goes wrong while backing up.

It has three public properties:

- `$exception`: an object that extends PHP's `Exception` class. It is highly likely that `$exception->getMessage()` will return more information on what went wrong.
- `$diskName`: a nullable string containing the name of the destination disk. If this is `null` then something probably went wrong before the backup could be copied to a destination.
- `$backupName`: a nullable string containing the name of the backup.

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

`Spatie\Backup\Events\BackupManifestWasCreated`

Internally the package will build up a manifest of files. This manifest contains the dumps of the databases and any files that are selected for backup. All the files in the manifest will be zipped.

It has one public property `$manifest` which is an instance of `Spatie\Backup\Tasks\Backup\Manifest`

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

`Spatie\Backup\Events\BackupZipWasCreated`

This event will be fired right after the zipfile - containing the dumps of the databases and any files that were selected for backup - is created, and before that zip will get copied over to the backup destination(s). You can use this event to do last minute manipulations on the created zip file.

It has one public property `$pathToZip` which contains a path to the created zipfile.

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

`Spatie\Backup\Events\DumpingDatabase`

This event will be fired before dumping the databases. You can use this event to do last minute manipulations on database dumper.

It has one public property `$dbDumper` which is an instance of a [dumper driver](https://github.com/spatie/db-dumper).
