# SRS-05: Backup Management

## 1. Overview
Backup Management module provides integration with Bacula/Bareos for backup job management, scheduling, and monitoring.

## 2. Functional Requirements

### 2.1 Backup Jobs
**FR-BACKUP-001**: System shall allow users to create backup jobs
- **Input**: Job name, client, fileset, schedule, storage pool
- **Output**: Created job with ID
- **Validation**: Valid client, fileset, schedule

**FR-BACKUP-002**: System shall allow users to list backup jobs
- **Output**: Job list with status, last run, next run
- **Filtering**: By status, client, schedule

**FR-BACKUP-003**: System shall allow users to view job details
- **Output**: Job configuration, history, statistics

**FR-BACKUP-004**: System shall allow users to run jobs manually
- **Input**: Job ID
- **Action**: Trigger immediate job execution

**FR-BACKUP-005**: System shall display job history
- **Output**: Job run history with status, duration, data transferred

### 2.2 Clients
**FR-BACKUP-006**: System shall list backup clients
- **Output**: Client list with status, last backup

**FR-BACKUP-007**: System shall display client details
- **Output**: Client configuration, job history

### 2.3 Storage Pools
**FR-BACKUP-008**: System shall allow users to create storage pools
- **Input**: Pool name, pool type, volume count
- **Output**: Created pool with ID

**FR-BACKUP-009**: System shall allow users to list storage pools
- **Output**: Pool list with type, volume count, usage

**FR-BACKUP-010**: System shall allow users to delete storage pools
- **Input**: Pool ID
- **Validation**: Pool must not be in use

### 2.4 Storage Volumes
**FR-BACKUP-011**: System shall allow users to create storage volumes
- **Input**: Pool ID, volume name, size
- **Output**: Created volume with ID

**FR-BACKUP-012**: System shall allow users to list storage volumes
- **Output**: Volume list with status, usage, expiration

**FR-BACKUP-013**: System shall allow users to update storage volumes
- **Input**: Volume ID, updated properties

**FR-BACKUP-014**: System shall allow users to delete storage volumes
- **Input**: Volume ID

### 2.5 Media Management
**FR-BACKUP-015**: System shall list backup media
- **Output**: Media list with label, type, status, location

**FR-BACKUP-016**: System shall display media details
- **Output**: Media properties, job history, usage

### 2.6 Dashboard Statistics
**FR-BACKUP-017**: System shall display backup dashboard statistics
- **Output**: Total jobs, running jobs, success rate, data backed up

### 2.7 Bconsole Integration
**FR-BACKUP-018**: System shall allow users to execute bconsole commands
- **Input**: Command string
- **Output**: Command output
- **Validation**: Allowed commands only

## 3. User Interface Requirements

### 3.1 Backup Dashboard
- Statistics cards (total jobs, running, success rate)
- Recent job activity
- Quick actions

### 3.2 Job Management
- Job list with filtering
- Job creation wizard
- Job detail view with history
- Job run controls

### 3.3 Storage Management
- Storage pool list and management
- Volume list and management
- Media inventory

## 4. API Endpoints

```
GET    /api/v1/backup/dashboard/stats
GET    /api/v1/backup/jobs
GET    /api/v1/backup/jobs/:id
POST   /api/v1/backup/jobs

GET    /api/v1/backup/clients
GET    /api/v1/backup/storage/pools
POST   /api/v1/backup/storage/pools
DELETE /api/v1/backup/storage/pools/:id

GET    /api/v1/backup/storage/volumes
POST   /api/v1/backup/storage/volumes
PUT    /api/v1/backup/storage/volumes/:id
DELETE /api/v1/backup/storage/volumes/:id

GET    /api/v1/backup/media
GET    /api/v1/backup/storage/daemons

POST   /api/v1/backup/console/execute
```

## 5. Permissions
- **backup:read**: Required for viewing jobs, clients, storage
- **backup:write**: Required for creating, updating, deleting, executing

## 6. Error Handling
- Bacula/Bareos connection errors
- Invalid job configuration
- Job execution failures
- Storage pool/volume errors
- Insufficient permissions

