> ## Documentation Index
> Fetch the complete documentation index at: https://ctpf.q-uestionable.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# ctpf db

> Database management commands

Database backup and reset operations.

## Commands

### `ctpf db backup`

Create a backup of the database.

```bash theme={null}
ctpf db backup [PATH]
```

**Arguments:**

| Argument | Description                                |
| -------- | ------------------------------------------ |
| `PATH`   | Optional. Custom path for the backup file. |

**Default location:** `~/.qai/backups/qai-{YYYY-MM-DD-HHMMSS}.db`

**Examples:**

```bash theme={null}
# Backup to default location
ctpf db backup
# Output: Backup created: /home/user/.qai/backups/qai-2025-04-10-143052.db

# Backup to custom path
ctpf db backup /tmp/my-backup.db
# Output: Backup created: /tmp/my-backup.db
```

<Tip>
  Run backups before destructive operations like reset, or before upgrading q-ai versions.
</Tip>

***

### `ctpf db reset`

Reset the database to a clean state. Creates an automatic backup before deletion.

```bash theme={null}
ctpf db reset [--yes]
```

**Options:**

| Option  | Description               |
| ------- | ------------------------- |
| `--yes` | Skip confirmation prompt. |

**What gets deleted:**

* All scan targets
* All runs, findings, and evidence
* All IPI campaigns and callback hits

**What's preserved:**

* Provider credentials (stored in OS keyring)
* Provider configurations
* Default settings

**Examples:**

```bash theme={null}
# Interactive reset with confirmation
ctpf db reset
# Output:
# ⚠️  This will delete all targets, runs, findings, and evidence.
# Settings and credentials will be preserved.
# Type RESET to confirm: RESET
# Backup created: /home/user/.qai/backups/qai-2025-04-10-143052.db
# Database reset complete.

# Non-interactive reset
ctpf db reset --yes
```

<Warning>
  Reset is irreversible. The automatic backup is your only recovery option.
</Warning>
