Monitoring the health of all backups | laravel-backup | Spatie

 SPATIE

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

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Laravel-backup](https://spatie.be/docs/laravel-backup/v3)  Monitoring-the-health-of-all-backups  Monitoring the health of all backups

 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)

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

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

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

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

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

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

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

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

- [ Sending notifications ](https://spatie.be/docs/laravel-backup/v3/sending-notifications/overview)
- [ Creating a custom sender ](https://spatie.be/docs/laravel-backup/v3/sending-notifications/creating-a-custom-sender)

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

- [ Adding Extra Files to the zip ](https://spatie.be/docs/laravel-backup/v3/advanced-usage/adding-extra-files-to-the-zip)
- [ Backing up a non-laravel application ](https://spatie.be/docs/laravel-backup/v3/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                                                                                                                                                                                                                                    `

Monitoring the health of all backups
====================================

###  On this page

1. [ Installation ](#content-installation)
2. [ Specifying which backups should be monitored ](#content-specifying-which-backups-should-be-monitored)
3. [ Getting notified of (un)healthy backups ](#content-getting-notified-of-unhealthy-backups)
4. [ Seeing an overview of all backups ](#content-seeing-an-overview-of-all-backups)

The package can check the health of every application it is installed into. A backup is considered unhealthy if the date of the last backup is too far in the past or if the storage needed for all backups too large.

Installation
--------------------------------------------------------------------------------------------

We recommend setting up a separate Laravel installation, preferably on a separate server. Doing it this way will ensure you will still get notified of unhealthy backups even if one of the applications you are monitoring is broken.

To install the monitor follow the regular [installation instructions](/laravel-backup/v3/installation-and-setup). Instead of scheduling the `backup:run` and `backup:clean` commands, you should schedule the monitor command.

```
//app/Console/Kernel.php

protected function schedule(Schedule $schedule)
{
   $schedule->command('backup:monitor')->daily()->at('03:00');
}
```

You can of course still schedule `backup:run` and `backup:clean` to backup the monitoring application itself.

Specifying which backups should be monitored
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

This is the part of the configuration where you can specify which applications should be monitored and when the monitor should consider the backups of a certain application unhealthy.

```
//config/laravel-backup.php

    /*
     *  In this array you can specify which backups should be monitored.
     *  If a backup does not meet the specified requirements the
     *  UnHealthyBackupWasFound-event will be fired.
     */
    'monitorBackups' => [
        [
            'name' => env('APP_URL'),
            'disks' => ['local'],
            'newestBackupsShouldNotBeOlderThanDays' => 1,
            'storageUsedMayNotBeHigherThanMegabytes' => 5000,
        ],

        /*
        [
            'name' => 'name of the second app',
            'disks' => ['local', 's3'],
            'newestBackupsShouldNotBeOlderThanDays' => 1,
            'storageUsedMayNotBeHigherThanMegabytes' => 5000,
        ],
        */
    ],
```

The `name` of a monitor should match the value you have specified in the `backup.name`-key of the config file in the application that is being backed up.

If you set `storageUsedMayNotBeHigherThanMegabytes` to `0` then the monitor will consider that the backup can use unlimited storage.

Getting notified of (un)healthy backups
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------

You can receive notifications when the monitor finds an (un)healthy backup. Read the section on [notifications](/laravel-backup/v3/sending-notifications/overview) to know more.

Seeing an overview of all backups
-----------------------------------------------------------------------------------------------------------------------------------------------------------

You can perform this command to see the status of all monitored destination filesystems.

```
php artisan backup:list
```

 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)
