Date: 2026-05-11
Time: 15:12
This page describes the automatic backup system designed for FTL2 modules, which creates timestamped copies of files before destructive operations (modify, delete). Backups are handled by the gate (not individual modules), use a two-phase discovery-then-execute protocol, and are especially valuable in AI-assisted workflows where operations may run without human review. Modules declare backup capability via docstring metadata; the gate's BackupManager orchestrates creation, storage, listing, and restoration.
--no-backupftl2discoverbackups), Phase 2 executes the operation with ftl2backupscreated metadata attachedBackup-Capable (Yes/No), Backup-Paths (which args contain target paths), Backup-Trigger (modify, delete, or both — default is modify,delete){original_path}.ftl2-backup-{YYYYMMDD}-{HHMMSS}--backup-dir / config backup.central_dir)Backup-Capable: NoModule docstring metadata declaration:
Backup-Capable: Yes
Backup-Paths: dest
Backup-Trigger: modify
CLI options:
ftl2 run -m file -i hosts.yml -a "path=/etc/app.conf state=absent" # backups enabled (default)
ftl2 run -m file -i hosts.yml -a "path=/tmp/test state=absent" --no-backup # skip backups
ftl2 run -m file -i hosts.yml -a "path=/etc/app.conf state=absent" --backup-dir /var/ftl2/backups
Backup management commands:
ftl2 backup list [path] # list all or path-specific backups
ftl2 backup show <backup-path> # show backup contents
ftl2 backup diff <backup-path> # diff backup vs current
ftl2 backup restore <backup-path> [--dry-run] [--force] # restore from backup
ftl2 backup prune --older-than 7d # prune by age
ftl2 backup prune --keep 3 # prune keeping N most recent
Configuration (ftl2.yml):
backup:
enabled: true
location: adjacent # or "central"
central_dir: /var/ftl2/backups
retention_days: 7
max_backups_per_file: 5
Python module implementation pattern:
def main(args: dict) -> dict:
if args.get("_ftl2_discover_backups"):
return {"backup_paths": discover_backups(args)}
backups_created = args.get("_ftl2_backups_created", [])
# ... normal module logic ...
BackupManager that orchestrates the backup flow — modules don't create backups themselvesArguments, Returns, Idempotent fieldssudo or alternative --backup-dir--no-backup to disable{path}.ftl2-backup-{YYYYMMDD}-{HHMMSS}Backup-Capable, Backup-Paths, Backup-Triggermodify,deleteftl2discoverbackups: true) then execution (ftl2backupscreated)backup.central_dir)Backup-Capable: No because its effects are unpredictableftl2 backup restore and ftl2 backup prune are the key management commandsretentiondays and maxbackupsperfile