# Snapshots

> Create, list, restore, and delete VM snapshots.

---

LLMS index: [llms.txt](/llms.txt)

---

Create, list, restore, and delete VM snapshots using libvirt's built-in snapshot support.

## Usage

```bash
# Create snapshot (default: shutdown VM first for disk consistency, then restore previous state)
uv run ansible-playbook playbooks/snapshot-vm.yaml -e vm_name=debian12-01 -e snap_action=create

# Create snapshot without shutdown (live snapshot, VM continues running)
uv run ansible-playbook playbooks/snapshot-vm.yaml -e vm_name=debian12-01 -e snap_action=create -e halt=false

# Create snapshot with custom name and description
uv run ansible-playbook playbooks/snapshot-vm.yaml -e vm_name=debian12-01 -e snap_action=create -e snapshot_name=before-upgrade -e snapshot_desc="pre-upgrade snapshot"

# List all snapshots
uv run ansible-playbook playbooks/snapshot-vm.yaml -e vm_name=debian12-01 -e snap_action=list

# Restore to snapshot (requires confirmation, restores VM state at snapshot time)
uv run ansible-playbook playbooks/snapshot-vm.yaml -e vm_name=debian12-01 -e snap_action=restore -e snapshot_name=before-upgrade -e confirm=true

# Delete snapshot
uv run ansible-playbook playbooks/snapshot-vm.yaml -e vm_name=debian12-01 -e snap_action=delete -e snapshot_name=before-upgrade
```

## Parameters

- `vm_name`: VM name (required)
- `snap_action`: `create` / `list` / `restore` / `delete` (required)
- `snapshot_name`: snapshot name (auto-generated for create; required for restore/delete)
- `snapshot_desc`: description (optional, create only)
- `halt`: shutdown VM before snapshot for disk consistency, then restore to previous state (optional, create only, default: `true`)
- `confirm`: safety flag (required for restore and delete)

## Behavior

- **halt=true (default)**: If VM is running → shutdown → snapshot → start (restore running state). If VM is off → snapshot → remain off (preserve off state).
- **halt=false**: Create snapshot while VM is running (live snapshot). Faster but may have incomplete disk writes.
- **Restore** returns the VM to the exact state at snapshot time (running or off depending on snapshot state).

---

Backlinks:

- [Documentation](/docs/)
- [Getting Started](/docs/getting-started/)
