# Timeshift Role Manages Timeshift system snapshots for backup and rollback capabilities. ## Purpose This role installs and configures Timeshift, a system restore utility for Linux. It can automatically create snapshots before playbook execution to enable easy rollback if something goes wrong. ## Features - Installs Timeshift package - Creates automatic snapshots before playbook runs - Configurable snapshot retention - Easy rollback capability ## Variables ### Installation - `timeshift_install` (default: `true`) - Install Timeshift package ### Snapshot Settings - `timeshift_auto_snapshot` (default: `true`) - Automatically create snapshot before playbook execution - `timeshift_snapshot_description` (default: `"Ansible playbook snapshot"`) - Description for snapshots - `timeshift_snapshot_tags` (default: `["ansible", "pre-playbook"]`) - Tags for snapshots - `timeshift_snapshot_type` (default: `"RSYNC"`) - Snapshot type: RSYNC or BTRFS ### Retention - `timeshift_keep_daily` (default: `7`) - Keep daily snapshots for N days - `timeshift_keep_weekly` (default: `4`) - Keep weekly snapshots for N weeks - `timeshift_keep_monthly` (default: `6`) - Keep monthly snapshots for N months ### Location - `timeshift_snapshot_location` (default: `"/timeshift"`) - Where to store snapshots ## Usage ### Basic Usage Add to your playbook: ```yaml roles: - { role: timeshift, tags: ['timeshift', 'snapshot'] } ``` ### Disable Auto-Snapshot ```yaml roles: - { role: timeshift, tags: ['timeshift'] } ``` In host_vars or group_vars: ```yaml timeshift_auto_snapshot: false ``` ### Manual Snapshot ```bash # On the target host sudo timeshift --create --comments "Manual snapshot before changes" ``` ### Rollback ```bash # List snapshots sudo timeshift --list # Restore from snapshot sudo timeshift --restore --snapshot 'YYYY-MM-DD_HH-MM-SS' # Or use the Makefile target make timeshift-restore HOST=dev02 SNAPSHOT=2025-12-17_21-30-00 ``` ## Integration with Playbooks The role is designed to be run early in playbooks to create snapshots before making changes: ```yaml roles: - { role: timeshift, tags: ['timeshift', 'snapshot'] } # Create snapshot first - { role: base } - { role: development } # ... other roles ``` ## Dependencies - Debian/Ubuntu-based system - Root/sudo access ## Notes - Snapshots require significant disk space - RSYNC snapshots are larger but work on any filesystem - BTRFS snapshots are smaller but require BTRFS filesystem - Snapshots exclude `/home` by default (configurable)