Monitoring the health of all backups | 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)  Monitoring-the-health-of-all-backups  Monitoring the health of all backups

 Version   v1      

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

  Monitoring the health of all backups    
- [ 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)

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

###  On this page 

1. [ Run and schedule ](#content-run-and-schedule)

- Monitor backup age, storage consumption and destination reachability.
- Use a separate monitoring host when possible, so a failed application cannot also silence its monitor.
- Register the [service provider](../installation-and-setup) and configure disks that can read each application's backup directory.
- Each monitor's `name` must match the originating application's `backup.name`.

```
use spatie_backup::{Config, config::MonitoredBackupConfig};
use std::collections::BTreeMap;

let mut config = Config::default();
config.monitor_backups = vec![MonitoredBackupConfig {
    name: "invoices".into(),
    disks: vec!["backups".into()],
    health_checks: BTreeMap::from([
        ("MaximumAgeInDays".into(), 1.5),
        ("MaximumStorageInMegabytes".into(), 5000.0),
    ]),
}];
```

- `MaximumAgeInDays` fails for empty destinations and when the latest backup's age reaches the configured number of days. Fractional days are supported.
- `MaximumStorageInMegabytes` fails when total size exceeds the configured binary-megabyte limit (1 MiB = 1,048,576 bytes). Equality passes.
- Remove a rule to disable it. Unknown rule names fail explicitly. See [custom health checks](creating-your-custom-health-check) to register another rule.
- Inventories are immutable snapshots. A fresh monitor run reads the disks again.

Run and schedule
--------------------------------------------------------------------------------------------------------

- `backup:list` prints destination statuses as JSON without notifications.
- `backup:monitor` emits healthy or unhealthy events and sends configured notifications. Any unhealthy destination produces an unsuccessful exit code.
- An unreachable disk appears as `reachable = false` with an `IsReachable` failure.

```
cargo run -- backup:list
cargo run -- backup:monitor
```

- Schedule monitoring in the application and run Laravel's `schedule:run` every minute:

```
let app = laravel::Application::configure()
    .with_providers(|providers| { providers.add(spatie_backup::service_provider()); })
    .with_schedule(|schedule, _| {
        schedule.command("backup:monitor").daily_at("03:00");
    })
    .create();
```

- Configure delivery channels and recipients in the [notification guide](../sending-notifications/overview).

 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)
