4.0 KiB
4.0 KiB
AGENTS.md
Repo Overview
- Purpose: run
restic backupagainst a Wasabi S3-compatible repository. - Main entry point:
travel-backup-script.py. - Dependencies are intentionally minimal:
- Python standard library
python-dotenv- External binary:
resticmust already be installed and available onPATH
- There are currently no tests, package metadata files, or CI config in this repo.
File Map
travel-backup-script.py: single-script CLI implementation.requirements.txt: Python dependency list (python-dotenvonly).README.md: user-facing setup and usage docs..env.example: template for environment variables..gitignore: ignores.env.*files (except.env.example).
Current Script Behavior
The script uses two subcommands: init and backup.
- Loads
.env.localautomatically viaload_dotenv(".env.local"). - Parses CLI args into subcommands with shared repo flags and backup-specific source flags.
- Resolves the repository string:
--repository/RESTIC_REPOSITORYtakes priority (validated againsts3:s3.<region>.wasabisys.com/...format).- Otherwise built from
--bucket/WASABI_BUCKET,--region/WASABI_REGION,WASABI_ENDPOINT, and--prefix/RESTIC_PREFIX.
- Constructs a minimal subprocess environment for
restic:WASABI_ENDPOINT,AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY,RESTIC_PASSWORDPATH,HOMEif presentSYSTEMROOT,SystemRoot,COMSPEC(Windows-specific, required for DNS resolution and shell access)
- For
init: runsrestic initagainst the resolved repository. - For
backup: resolves input from--source,--file, orFILE_PATH_CONFIG_PATHenv var, then runsrestic backup. - Prints the repo, command, and redacted env status before optionally executing
restic.
Known Drift / Things To Watch
- The JSON config file must contain a top-level
pathskey with a non-empty array of non-empty strings. --sourceand--fileare mutually exclusive; one of them orFILE_PATH_CONFIG_PATHis required for backup.--regionhas no default — it must be provided via CLI orWASABI_REGIONwhen not using--repository.
Local Development Workflow
Use this order when changing the repo:
- Read
travel-backup-script.pyfirst. Nearly all behavior lives there. - Treat
README.mdas partially authoritative only after comparing it to the script. - If you change CLI flags, env loading, or repository construction, update code, README, and
.env.examplein the same change. - Preserve secret-handling behavior. Do not print raw credentials.
Suggested Verification
Because the repo has no automated tests, prefer lightweight verification:
- Static review of argument parsing and env handling.
- Dry-run init:
python travel-backup-script.py init --bucket <bucket> --region <region> --dry-run
- Dry-run backup with a direct source:
python travel-backup-script.py backup --source <path> --bucket <bucket> --region <region> --dry-run
- Dry-run backup with a JSON config file:
python travel-backup-script.py backup --file <config.json> --bucket <bucket> --region <region> --dry-run
Avoid real backup runs unless the user explicitly asks for them and valid credentials are present.
Editing Guidelines
- Keep the implementation as a simple single-file CLI unless the user asks for a larger refactor.
- Favor backwards-compatible flag changes where practical.
- Be careful with subprocess environment changes:
PATHmust remain available soresticcan be found.HOMEis intentionally forwarded when present.- On Windows,
SYSTEMROOTandCOMSPECare required for DNS resolution and shell access.
- Do not commit real
.env.localor other secret files. - If adding tests later, prefer small CLI/unit tests around:
build_repoload_sourcesresolve_repo(priority order, validation)- missing
--buckethandling - env minimization/redaction behavior
Agent Notes
- Start discovery from the script, not the README.
- Keep
README.md,.env.example, and the script aligned when flags change.