Skip to content
RU
← All articles

Backup job heartbeat: signal only after a verified archive

In brief:

Send a backup heartbeat only after the job finishes and its archive passes checks. A safe sequence is temporary file → format check → atomic rename → local size record → monitor request. An HTTP 200 response from the endpoint does not by itself prove the intended monitor recorded a ping; verify its last-ping time in the dashboard.

Completed backup archive sending a signal to monitoring
A heartbeat should mean the operation finished and passed checks.

A cron job starting on schedule does not mean it saved usable data. A heartbeat says the job reached a chosen point, so place it after every required check rather than at script start or in a finally block. A passive monitor can then detect a missed run. Create one through enterno heartbeat monitoring. General website uptime monitoring is a different signal from the completion of a backup archive.

Backup storage system with a signal from a completed archive
No signal should be sent after a failed job.

Verify the archive before the heartbeat

The repository includes an executable backup_and_ping.sh for a file directory. It uses set -euo pipefail, removes an incomplete .partial file on failure, checks that the tar archive is nonempty and readable, then renames it. Only then does it call the heartbeat endpoint. The GNU tar manual covers archive listing and verification. Listing members is a format smoke test, not a substitute for a restore rehearsal.

export BACKUP_SOURCE=/srv/app-data
export BACKUP_DEST=/srv/backups/app-$(date -u +%F).tar.gz
export HEARTBEAT_URL=https://enterno.io/api/heartbeat/YOUR_PRIVATE_TOKEN
flock -n /run/lock/app-backup.lock bash backup_and_ping.sh
# Local fixture: success → backup_bytes=161, heartbeat_sent=1
# missing-source → exit 2, no archive, receiver hits: 0

The local fixture created a 161-byte archive and sent exactly one request to its test receiver. With a missing source directory, tar exited 2; no final archive or heartbeat was produced. The script, method.py and captured result are in the topic folder. The 161 bytes describe the fixture only. flock prevents concurrent cron runs from writing the same output; set its path and permissions for your deployment.

StageConditionRecord
CreateCommand exits 0stderr and duration
CheckFile is nonempty and format readableSize and local checksum
PublishArchive moved to final nameTime and nonsecret path
HeartbeatEvery earlier stage succeededLast accepted ping in the dashboard

Use a database-specific validation step

A file tar is not a consistent backup of a running database. For MariaDB, consider mariadb-dump --single-transaction --quick and use pipefail if piping to gzip; the MariaDB manual explains limits for nontransactional tables. For PostgreSQL, pg_dump -Fc produces a custom archive that pg_restore -l can list, per the PostgreSQL manual. With restic, exit 0 means a complete backup, while exit 3 indicates unreadable source files and an incomplete snapshot, according to restic docs. These adaptations require restore tests on your own data. Our fixture exercised tar only.

Store archive size and checksum in a local log or protected metrics system. The current enterno /api/heartbeat/{token} endpoint does not persist archive size as a separate field; adding ?size=... cannot create that measurement. The heartbeat detects a missed signal. Storage integrity and recovery need other checks. For the public site, pair this with a content check. The launch checklist keeps those signals separate.

HTTP 200 does not validate the token

To avoid token enumeration, the endpoint gives the same response for an unknown and inactive token. A safe request using a fabricated token returned HTTP 200 and {"status":"ok","msg":"Acknowledged"}. After setup, make one authorized test run and inspect the intended monitor’s last-ping timestamp in the dashboard. If it did not move, check the token, monitor status and URL. The HTTP response alone did not prove receipt.

Keep the token URL in a restricted configuration file and avoid set -x. Do not print it into shared CI logs. Set heartbeat interval and grace to accommodate normal backup duration. If weekends are intentionally quiet, configure a schedule rather than silencing all alerts. After the first successful ping, simulate a missed run on a safe staging job and confirm detection. Do not skip the sole production backup to test an alert.

How we made this guide

The local test ran the actual Bash tar script against a temporary directory and a receiver on 127.0.0.1: one success and one failure, with no real database or production token. A separate request with a fabricated token confirmed the public endpoint response without changing a monitor. Scripts and output are in the topic folder. SerpAPI snapshots cover Google US and Yandex Moscow. Wordstat region 225 returned no estimate for the exact Russian phrase and 411 for a broader backup-monitoring query; that broader volume cannot be assigned to heartbeats.

FAQ

Why is there a heartbeat when the archive is corrupt?

The signal may be sent too early or the check may be too weak. Add format checks and periodic restore rehearsals.

Does HTTP 200 prove the ping was recorded?

No. Check the intended monitor’s last-ping time; unknown tokens also receive 200.

Can enterno store archive size with the heartbeat?

The current endpoint does not persist size as a metric. Record bytes locally or in a separate metrics system.

Should restic exit 3 send a success heartbeat?

No. It indicates an incomplete snapshot. Inspect unreadable files and report that failure separately.

Sources

Check your website right now

Monitor your site continuously →
More articles: Monitoring
Monitoring
Check if Website Is Accessible from Russia: Blocks, TSPU, CDN
15.06.2026 · 2 840 views
Monitoring
How to Check if a Site Is Blocked in Russia (RKN)
15.06.2026 · 1 419 views
Monitoring
Website Not Loading: Why It Happens and a 10-Step Fix Checklist
23.06.2026 · 1 353 views
Monitoring
Top 10 Website Monitoring Services 2026: Features and Pricing
01.04.2026 · 1 193 views