---
title: "Monitor BorgBackup runs with return codes"
url: "https://cronmissed.com/guides/borg.md"
canonical_url: "https://cronmissed.com/guides/borg"
last_updated: "2026-10-22"
type: "how-to"
summary: "Borg returns 0 for success, 1 for a warning and 2 for an error. Pass the return code to CronMissed and choose which counts as a failure."
related: ["https://cronmissed.com/guides.md", "https://cronmissed.com/guides/restic.md", "https://cronmissed.com/guides/rsync.md", "https://cronmissed.com/guides/pg-dump.md", "https://cronmissed.com/learn/exit-codes-and-failure-signals.md"]
---

# Monitor BorgBackup runs with return codes

> **For AI agents:** the complete index of CronMissed pages is [llms.txt](https://cronmissed.com/llms.txt). Every page is also served as markdown at its URL plus .md.

Borg returns 0 for success, 1 for a warning and 2 for an error. Pass the return code to CronMissed and choose which counts as a failure.

BorgBackup separates warnings from errors: return code 1 means the operation finished but with warnings, 2 means it did not. The difference matters for a backup that finishes with a vanished file. Send the code to CronMissed and decide what you consider a failure.

## How can a scheduled job fail silently on BorgBackup?

- Return code 1 means the operation reached its normal end but there were warnings. Borg logs them at WARNING level, which nobody sees without the log.
- Return code 2 is a generic error: a fatal error, or an exception, so the operation did not reach its normal end.
- With BORG_EXIT_CODES=modern, specific errors use codes 3 to 99, specific warnings use 100 to 127, and a code of 128 plus N means the process was killed by signal N (137 is kill -9).
- Borg writes log messages to standard error, and the docs say to check the log levels and the return code to separate error, warning and success.

## What are the limits of BorgBackup?

| Limit | What the documentation says |
| --- | --- |
| 0 | Success. |
| 1 | Generic warning: the operation ended normally, with warnings. |
| 2 | Generic error. |
| 3 to 99, 100 to 127 | Specific errors and specific warnings, when BORG_EXIT_CODES=modern is set. |
| 128+N | Killed by signal N. |

## How do you add a CronMissed ping to BorgBackup?

The script below reports the start, runs the backup, and sends the return code. CronMissed counts only 0 as success. Add `--show-rc` to see the code in the log, and set the repository and passphrase in the environment.

```
#!/bin/sh
# borg backup: reports the start, the exit status and the last 100 kB of output to CronMissed.
# borg reads BORG_REPO and BORG_PASSCOMMAND from the environment.
PING_URL="https://ping.cronmissed.com/5f0c1b2e-7a3d-4c8e-9b61-2d4f8a7e3c10"
curl -fsS --max-time 10 --retry 5 --retry-connrefused -o /dev/null "$PING_URL/start"
output=$(borg create --stats "$BORG_REPO::{hostname}-{now}" /path/to/data 2>&1)
status=$?
printf '%s\n' "$output" | tail -c 100000 | curl -fsS --max-time 10 --retry 5 --retry-connrefused -o /dev/null --data-binary @- "$PING_URL/$status"
exit $status
```

If a warning (code 1) should still count as a good backup, map it after the run.

```sh
if [ "$status" -eq 1 ]; then status=0; fi
```

## Which check settings fit BorgBackup?

Create a cron check with the backup schedule and a grace based on the longest run. For a prune and compact job on a weekly schedule, create a second check, since a repository that is never pruned fills up quietly. A start ping records the duration of every run.

## How do you confirm the check works?

1. Run the script by hand with a test repository and confirm the start and result pings.
2. Run it against a repository path that does not exist and confirm the check goes down with a non-zero code.
3. Delete a source file mid-run (in a test) to see how your Borg version reports it, and decide whether to map the warning.

## Questions

### Should warnings count as failures?

It depends on the data. A warning for a file that vanished during the run is often harmless; a warning for an unreadable directory is not. Start strict, and map specific warnings once you know them.

### Does the check see the backup size?

The ping body can carry the end of Borg's statistics output. Pipe the output through tail -c 100000 as the script does, and read it in the ping log.

## Sources

- [BorgBackup documentation: general usage and return codes](https://borgbackup.readthedocs.io/en/stable/usage/general.html), read 22 October 2026

## Related pages

- [restic backups](https://cronmissed.com/guides/restic.md)
- [rsync backups](https://cronmissed.com/guides/rsync.md)
- [pg_dump database backups](https://cronmissed.com/guides/pg-dump.md)
- [Exit codes and failure signals](https://cronmissed.com/learn/exit-codes-and-failure-signals.md)

## Related

- [Monitor cron jobs on every platform: 24 guides](https://cronmissed.com/guides.md)
- [Monitor restic backups with exit codes](https://cronmissed.com/guides/restic.md)
- [Monitor rsync jobs by exit value](https://cronmissed.com/guides/rsync.md)
- [Monitor pg_dump backups with CronMissed](https://cronmissed.com/guides/pg-dump.md)
- [Exit codes and failure signals in cron jobs](https://cronmissed.com/learn/exit-codes-and-failure-signals.md)
