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

 SPATIE  

laravel-backup-go
=================

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Laravel-backup-go](https://spatie.be/docs/laravel-backup-go/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-go/v1) 

  Monitoring the health of all backups    
- [ Introduction ](https://spatie.be/docs/laravel-backup-go/v1/introduction)
- [ Installation and setup ](https://spatie.be/docs/laravel-backup-go/v1/installation-and-setup)
- [ Requirements ](https://spatie.be/docs/laravel-backup-go/v1/requirements)
- [ High level overview ](https://spatie.be/docs/laravel-backup-go/v1/high-level-overview)
- [ Questions and issues ](https://spatie.be/docs/laravel-backup-go/v1/questions-and-issues)
- [ About us ](https://spatie.be/docs/laravel-backup-go/v1/about-us)
- [ Testing ](https://spatie.be/docs/laravel-backup-go/v1/testing)
- [ Releasing ](https://spatie.be/docs/laravel-backup-go/v1/releasing)
- [ Changelog ](https://spatie.be/docs/laravel-backup-go/v1/changelog)
- [ Support us ](https://spatie.be/docs/laravel-backup-go/v1/support-us)

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

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

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

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

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

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

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

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

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

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

 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. [ Get notifications of healthy or unhealthy backups ](#content-get-notifications-of-healthy-or-unhealthy-backups)
4. [ Checking all backups ](#content-checking-all-backups)

The package can check the health of backups for every application where it is installed. A backup is unhealthy if the latest backup is too old or the backups require too much storage.

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

We recommend setting up a separate Laravel Go application for monitoring, preferably on a separate server. This ensures you can be notified even if an application you are monitoring is broken.

Use a central storage disk, like S3, for your backups. Local disks work too, but the monitor must be able to read them.

Follow the regular [installation instructions](../installation-and-setup), then schedule:

```
s.Command("backup:monitor").DailyAt("03:00")
```

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

```
cfg.Monitors = []backup.Monitor{
    {
        Name: "my-application",
        Disks: []string{"s3"},
        Checks: []backup.HealthCheck{
            backup.MaximumAge(24 * time.Hour),
            backup.MaximumStorage(5000 * 1024 * 1024),
        },
    },
}
```

`MaximumAge` fails when there are no backups or the newest backup is at least the configured age. `MaximumStorage` fails when total bytes exceed its limit. Remove a check if you don't need it. The monitor name must match the backup name of the application being backed up.

Reachability is checked first by listing the destination. Unreachable destinations skip other checks. Each operation takes a fresh listing. Default timestamp filenames supply the backup date. Custom filenames use storage modification times.

Get notifications of healthy or unhealthy backups
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Read the section on [notifications](../sending-notifications/overview). `backup:monitor` returns a nonzero exit status if any destination is unhealthy.

Checking all backups
--------------------------------------------------------------------------------------------------------------------

```
laravel backup:list
```

This command prints JSON with names, disks, reachability, backup dates, sizes and failed checks. It does not send notifications and exits successfully even when a destination is unhealthy. Applications can call `backup.From(ctx).Statuses(ctx, "")` for the same data.

 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)
