Advertisement

How to know if your backup did NOT work?

Zeynel -
13 minutes ago

Backup software can email you reports when they do their job. Your Windows task or Phython script may do it too, if you would want to. But how will you know if your automated task didn't work, backup was skipped, or your sleeping "server" didn't even turn on at all at defined time?

The answer is using a "heartbeat" checking service. For basic purposes, the free plan of healthchecks.io is more than enough for the most people. Let's dive into the details of using it.

How healthchecks.io work?

If a task doesn't run for some reason, it doesn't even know it didn't run. So you need an external tool or service to check this, the task itself won't send you notifications that it cannot run unless it is designed to do so.

healthchecks.io or similar "heartbeat monitoring services" (that's how it's called) let you create a "ping URL". Then you "ping" this URL to let it know that your service is working. This ping is rather a HTTP request than traditional ping, but you probably get the point.


Healthchecks.io project main page looks like this.

When the heartbeat monitoring service doesn't get the ping in expected time, it emails you about this. That's how you get notified for _abensence_ of something.


How to use healthchecks.io?

Here is how to use it in an example backup job operation. You can use this example to apply it to anywhere you can run a line of command.

1. Register for an account at https://healthchecks.io/. The free version will allow you to create 20 ping URLs, and currently don't have very strict limitations.

2. After registration, Create a project.

3. Although optional, I recommend you to create a Ping key. It'll allow you to create more friendly URLs. Go to Settings > Account. Find My Projects area, and click Settings next to your project name. Click Create next to the Ping key.

3. Now go to your project home page (by clicking it from top left). Switch to using "slug" by clicking slug in the Ping URL column..

4. Click the green Add check button.

5. In the popup box, fill the Name. You can use suggested value for Slug. Set period of your "task" which we'll talk about. The grace time will allow some flexibility for your task to run late. Click Save.

6. Click the Ping URL of the newly created item, it should look like this:

https://hc-ping.com/6xD5QGLrF-B3F-sdFE3Ukw/defkey-backup-job

7. Now, let's say you have a backup job that runs every day, and you want to know whenever it is skipped. You'll need to run a line of command after it's successfully finished. Many programs will allow you to do this via a configuration, but some may not in their free version.

You'll need to run this line to ping the endpoint you created in healthchecks.io

curl [your ping url]

For example;

curl https://hc-ping.com/6xD5QGLrF-B3F-sdFE3Ukw/defkey-backup-job    

That's it. The "check" in healthchecks.io will not be active until the first ping is received, so either manually run the backup job (or whatever task it is) to test if the pinging works or check later (after its scheduled time) if it's working.

If your program doesn't accept that command but accepts batch files, you can create a .bat file with the same line (curl ...) and use it.

Periodic reports

You can also get periodic reports from healthchecks.io, which will be useful if you somehow skip a notification email or forget about it. These email reports can be configured in Settings > Email reports

Conclusion

That's basically how you let yourself know if a task didn't run at all at the planned time. This article handled the basics of pinging your heartbeat monitoring service. For more robust pinging, you may want to create a Python script with a retrying mechanism, logging, etc. But for basic purposes, the method explained here should be sufficient.

Did you find this article useful?
0 0
Share this page on:



Only registered users can post links.
Checking site status...
 
No comments yet. Ask, or type the first one!