Overview

Date: 2026-05-11

Time: 15:12

Overview

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.

Key Concepts

Commands and Syntax

Module 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 ...

Relationships

Exam-Relevant Points