Skip to content

Script for launchd and systemd - #4

Merged
felipecastrotc merged 9 commits into
developfrom
script_for_launchd_and_systemd
Aug 23, 2025
Merged

Script for launchd and systemd#4
felipecastrotc merged 9 commits into
developfrom
script_for_launchd_and_systemd

Conversation

@felipecastrotc

Copy link
Copy Markdown
Owner

Context

This PR introduces a scheduled backup system for the bare backup CLI tool, enabling daily automated backups on both Linux (systemd) and macOS (launchd).
It also simplifies environment management, logging, and connectivity handling (with optional Tailscale support).
In addition, the pixi.lock file has been streamlined by removing unnecessary dev/test dependencies, and a new executable bare_runner has been added.


Description

  • Added a new backup runner script (bare_runner) for scheduling automated backups.
  • Provided detailed packaging/README.md documentation for setting up scheduled backups on Linux and macOS.
  • Improved Restic integration by allowing explicit bin_path for restic/rustic binaries.
  • Updated pixi.lock to drop extra dev dependencies (pytest, mkdocs, mypy, etc.) and add yaml as a required dependency.
  • Introduced .gitignore rule to prevent committing local launchd plist files (com.user.barebackup.plist).
  • Exposed bare_runner as an installable script via pyproject.toml.

Changes in the Codebase

New

  • src/bare/scripts/schedule_runner.py

    • Daily backup runner:

      • Manages logging, state tracking, and Tailscale.
      • Detects if a backup was already performed today.
      • Runs backup only if the server is reachable.
      • Gracefully manages Tailscale startup/shutdown when needed.
      • Supports --dry-run mode.
  • packaging/README.md

    • Detailed step-by-step guide for Linux (systemd) and macOS (launchd) scheduled backups.
    • Includes troubleshooting, environment variable references, and alternative laptop-friendly setup.

Modified

  • .gitignore

    • Added: */com.user.barebackup.plist
  • pyproject.toml

    • Added new entry point:

      [project.scripts]
      bare_runner = "src.bare.scripts.schedule_runner:main"
  • src/bare/bare/restic.py

    • Changed constructor to accept bin_path.
    • Uses shutil.which to detect restic or rustic binaries if bin_path is not given.
    • Safer handling of RESTIC_PASSWORD.
  • src/bare/main.py

    • default_var now includes bin_path.
    • get_restic_instance passes bin_path into Restic.

Changes Outside the Codebase

  • Documentation added in packaging/README.md (guides for Linux/macOS automation).

  • Users must manually create and configure:

    • ~/.config/systemd/user/bare-backup.* (Linux)
    • ~/Library/LaunchAgents/com.user.barebackup.plist (macOS)

@felipecastrotc felipecastrotc self-assigned this Aug 23, 2025
@felipecastrotc felipecastrotc added the enhancement New feature or request label Aug 23, 2025
@felipecastrotc
felipecastrotc merged commit d41399e into develop Aug 23, 2025
3 checks passed
@felipecastrotc
felipecastrotc deleted the script_for_launchd_and_systemd branch August 23, 2025 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant