Skip to main content

resticbackups3 (rbs3)

A command-line tool that turns restic and S3-compatible storage (Cloudflare R2 first) into "init once, then back up from cron":

rbs3 init <profile>
rbs3 backup <profile> --mail
rbs3 cronjob <profile> "0 4 * * *" --mail --silent

Status: early development. rbs3 init and rbs3 backup (with retention, prune, check and email reports) work; restore and cron come next.

Create a profile

rbs3 init <profile> --env-file creds.env --config settings.toml

Credentials can come from an env file (--env-file), this shell's environment (--env-var), flags (--restic-password=…) or prompts. They combine, with flags first, then the env file, then the environment, and anything still missing is asked for. Prefer the env file or the prompts: secrets given as flags end up in shell history.

Key Required
RESTIC_REPOSITORY yes, s3:https://<account>.r2.cloudflarestorage.com/<bucket>[/<prefix>]
AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, RESTIC_PASSWORD yes
AWS_DEFAULT_REGION no, default auto
SMTP_SERVER no; empty means no email reports
SMTP_PORT, SMTP_SECURITY (starttls/ssl) defaults 587 / starttls
SMTP_USER, SMTP_PASSWORD, MAIL_TO when SMTP_SERVER is set
MAIL_FROM no, default SMTP_USER

Before saving, init checks everything it can and prints ✔ or ✖ with a reason for each:

  • restic is installed and 0.16 or newer (if not, it prints the install command for your distro);
  • the S3 keys can list, write and delete in the bucket (an R2 token with an IP allow-list is named as such, with this machine's public IP);
  • the repository exists and the password opens it, or, if there is none yet, it offers to create one (--yes creates it without asking);
  • the SMTP login works, if email is configured, and it can send a test email.

If a check fails, nothing is saved unless you answer "save anyway" at the prompt.

Without --config, the settings are asked for one by one. The profile is saved as /etc/resticbackups3/<profile>/.env (root only, 0600) and config.toml (0644). After that you may delete your own copies, but keep RESTIC_PASSWORD in a password manager: without it no backup can be restored.

Back up

rbs3 backup <profile> [--mail] [--silent] [--dry-run]

All sources go into one snapshot, tagged rbs3 and profile:<profile>. Before it starts, rbs3 removes stale repository locks and opens the repository; afterwards it shows the repository size, the latest snapshot's restore size and the profile's snapshot count. A relative exclude pattern is rooted at each source (thumbs skips <source>/thumbs, **/*.tmp any .tmp file in it); an absolute one is used as-is. If [freshness_check] is set, a stale or missing matching file is reported as a warning.

After each backup rbs3 maintains the repository:

  • restic forget with the [retention] keep-* values runs every time. It looks at the profile's snapshots only (--tag profile:<profile>) as one group, so a new hostname or a changed source list does not start a separate retention series.

  • restic prune runs only on a prune day: today is maintenance.prune_weekday ("" = any day) and at least prune_interval_days calendar days have passed since the last successful prune (0 = no minimum). With the defaults (sun, 7) that is every Sunday; a missed Sunday waits for the next one.

  • restic check --read-data-subset <check_subset> runs right after each prune.

  • backup, forget, prune and check each wait up to 2 minutes for a lock held by another restic run (a backup or prune of another profile in the same repository, a manual restic command).

  • prune and check are stopped after 12 hours, so a hung one cannot hold the profile's lock (and block every later run) for ever. restic is stopped as Ctrl+C would, so it removes its lock.

  • A failed forget, prune or check makes the run FAILED. A failed prune is retried on the next run. A last prune dated after today (a wrong clock) is not counted, with a warning.

  • The last backup, prune and check (time and result) are kept in /var/lib/resticbackups3/<profile>/state.json.

  • --silent prints nothing but errors; --dry-run shows what would be uploaded, and runs no maintenance.

  • Each run writes /var/log/resticbackups3/<profile>/backup/<time>.txt, with secrets replaced by ***. Logs older than report.log_keep_days are removed.

  • Only one run per profile at a time: a second one exits at once (and sends no mail: the run that is still going will).

  • Exit codes: 0 OK, 3 warning (snapshot made, but some files could not be read), 1 failed, 75 another run of this profile is still going, 130 cancelled.

Email reports

--mail sends the report to MAIL_TO with the profile's SMTP settings; a profile without SMTP_SERVER refuses --mail before backing up. report.mail_on picks which runs are mailed: always (the default), warning (warnings and failures) or failure.

  • The subject reads [OK] rbs3 <profile> backup · 2026-11-29 · 4m 12s · <host>, with WARNING or FAILED in place of OK.
  • The mail has a plain-text part (the console summary) and an HTML part: a green, amber or red status banner, then errors and warnings, this run, maintenance and the repository. On a warning or failure it adds the log's last 40 lines and the log file's path. Inline styles and tables only, so Gmail and Outlook show it as meant, on a phone too.
  • A run that fails before it starts (a damaged config.toml, say) is still mailed, when the SMTP settings can be read.
  • Sending is tried 3 times, 5 and 30 seconds apart; a permanent refusal (a wrong login, an unknown recipient: any 5xx answer) only once. A mail that cannot be sent is written to the log and stderr; the exit code stays the backup's.
  • A --dry-run report says (dry run) after backup in the subject and the banner.

Install

Needs Linux, Python 3.12 or newer, and restic 0.16 or newer.

Tool Install Update
pipx pipx install resticbackups3 pipx upgrade resticbackups3
uv uv tool install resticbackups3 uv tool upgrade resticbackups3
pip (in a venv) pip install resticbackups3 pip install --upgrade resticbackups3

Run rbs3 as your normal user; it asks for sudo itself when it needs it.

Development

python -m venv .venv && . .venv/bin/activate
pip install -e ".[dev]" ruff mypy
git config core.hooksPath .githooks   # blocks commits containing strings from notes/deny-list.txt
ruff check . && ruff format --check . && mypy && pytest -n auto

tests/test_integration.py runs the checks against a real restic and S3 endpoint when RBS3_IT_ENDPOINT, RBS3_IT_BUCKET, RBS3_IT_KEY and RBS3_IT_SECRET are set. CI starts Versity Gateway for it.

Pull request titles follow Conventional Commits; a merged feat: or fix: publishes a release.

License

MIT

Metadata

Release files for resticbackups3 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for resticbackups3 0.5.0
File Size Uploaded Provenance Actions
resticbackups3-0.5.0.tar.gz 83.5 kB With provenance Details for resticbackups3-0.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for resticbackups3 0.5.0
File Interpreter ABI Platform Actions
resticbackups3-0.5.0-py3-none-any.whl Python 3 none any Details for resticbackups3-0.5.0-py3-none-any.whl

Total release size: 188.4 kB

Release files / resticbackups3-0.5.0.tar.gz

Download URL resticbackups3-0.5.0.tar.gz
Size 83.5 kB
Tags Source
SHA-256 checksum
How to use checksums
97f8cfe52340d0e300b874d9e8332a0db053aa34ac53efad23ce87b6e56932a5
BLAKE2b-256 checksum
How to use checksums
817237dda96b5141788e94a534dc8b5ffb4125c0b5143d3ca457f21dea0da452
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Release files / resticbackups3-0.5.0-py3-none-any.whl

Download URL resticbackups3-0.5.0-py3-none-any.whl
Size 104.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9912fa87b4799b9c6b6b1c16dacd82e0e12ae00edd8610f97834fd329eefa599
BLAKE2b-256 checksum
How to use checksums
8f2ee76703bd515b900f7fd05622388425282271461e94b469f14bc90825ef86
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Security for resticbackups3 0.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for resticbackups3-0.5.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page