# SRS-07: Snapshot & Replication

## 1. Overview
Snapshot & Replication module provides ZFS snapshot management and remote replication task configuration.

## 2. Functional Requirements

### 2.1 Snapshot Management
**FR-SNAP-001**: System shall allow users to create snapshots
- **Input**: Dataset name, snapshot name
- **Output**: Created snapshot with timestamp
- **Validation**: Dataset exists, snapshot name uniqueness

**FR-SNAP-002**: System shall allow users to list snapshots
- **Output**: Snapshot list with name, dataset, created date, referenced size
- **Filtering**: By dataset, date range, name

**FR-SNAP-003**: System shall allow users to view snapshot details
- **Output**: Snapshot properties, dataset, size, creation date

**FR-SNAP-004**: System shall allow users to delete snapshots
- **Input**: Snapshot ID
- **Validation**: Snapshot not in use

**FR-SNAP-005**: System shall allow users to rollback to snapshot
- **Input**: Snapshot ID
- **Warning**: Data loss warning required
- **Action**: Rollback dataset to snapshot state

**FR-SNAP-006**: System shall allow users to clone snapshots
- **Input**: Snapshot ID, clone name
- **Output**: Created clone dataset

**FR-SNAP-007**: System shall display snapshot retention information
- **Output**: Snapshots marked for expiration, retention policy

### 2.2 Replication Management
**FR-SNAP-008**: System shall allow users to create replication tasks
- **Input**: Task name, source dataset, target host, target dataset, schedule, compression
- **Output**: Created replication task with ID
- **Validation**: Valid source dataset, target host reachable

**FR-SNAP-009**: System shall allow users to list replication tasks
- **Output**: Task list with status, last run, next run

**FR-SNAP-010**: System shall allow users to view replication task details
- **Output**: Task configuration, history, status

**FR-SNAP-011**: System shall allow users to update replication tasks
- **Input**: Task ID, updated configuration

**FR-SNAP-012**: System shall allow users to delete replication tasks
- **Input**: Task ID

**FR-SNAP-013**: System shall display replication status
- **Output**: Task status (idle, running, error), progress percentage

**FR-SNAP-014**: System shall allow users to run replication manually
- **Input**: Task ID
- **Action**: Trigger immediate replication

### 2.3 Replication Configuration
**FR-SNAP-015**: System shall allow users to configure replication schedule
- **Input**: Schedule type (hourly, daily, weekly, monthly, custom cron)
- **Input**: Schedule time

**FR-SNAP-016**: System shall allow users to configure target settings
- **Input**: Target host, SSH port, target user, target dataset

**FR-SNAP-017**: System shall allow users to configure compression
- **Input**: Compression type (off, lz4, gzip, zstd)

**FR-SNAP-018**: System shall allow users to configure replication options
- **Input**: Recursive flag, auto-snapshot flag, encryption flag

### 2.4 Restore Points
**FR-SNAP-019**: System shall display restore points
- **Output**: Available restore points from snapshots

**FR-SNAP-020**: System shall allow users to restore from snapshot
- **Input**: Snapshot ID, restore target

## 3. User Interface Requirements

### 3.1 Snapshot & Replication Dashboard
- Statistics cards (total snapshots, last replication, next scheduled)
- Quick actions (create snapshot, view logs)

### 3.2 Tabs
- **Snapshots**: Snapshot list and management
- **Replication Tasks**: Replication task management
- **Restore Points**: Restore point management

### 3.3 Snapshot List
- Table view with columns (name, dataset, created, referenced, actions)
- Search and filter functionality
- Pagination
- Bulk actions (select multiple)

### 3.4 Replication Task Management
- Task list with status indicators
- Task creation wizard
- Task detail view with progress

### 3.5 Create Replication Modal
- Task name input
- Source dataset selection
- Target configuration (host, port, user, dataset)
- Schedule configuration
- Compression and options

## 4. API Endpoints

```
GET    /api/v1/snapshots
GET    /api/v1/snapshots/:id
POST   /api/v1/snapshots
DELETE /api/v1/snapshots/:id
POST   /api/v1/snapshots/:id/rollback
POST   /api/v1/snapshots/:id/clone

GET    /api/v1/replication/tasks
GET    /api/v1/replication/tasks/:id
POST   /api/v1/replication/tasks
PUT    /api/v1/replication/tasks/:id
DELETE /api/v1/replication/tasks/:id
POST   /api/v1/replication/tasks/:id/run
GET    /api/v1/replication/tasks/:id/status

GET    /api/v1/restore-points
POST   /api/v1/restore-points/restore
```

## 5. Permissions
- **storage:read**: Required for viewing snapshots and replication tasks
- **storage:write**: Required for creating, updating, deleting, executing

## 6. Error Handling
- Invalid dataset
- Snapshot not found
- Replication target unreachable
- SSH authentication failure
- Replication task errors
- Insufficient permissions

