Home · Developers · Guides · Advanced Backup and Disaster Recovery

Operations

Advanced Backup and Disaster Recovery

Backup and restore

Overview

The Advanced Backup and Disaster Recovery System provides comprehensive backup scheduling, verification, multi-backend storage, and disaster recovery planning with automated recovery execution.

Components

AdvancedBackup

The advanced backup manager with comprehensive backup and disaster recovery features.

Location: novacoder/backup/advanced.py

Key Features:

  • Automated Scheduling: Thread-based backup scheduling with configurable intervals
  • Backup Types: Full, incremental, and differential backups
  • Verification: Checksum verification for backup integrity
  • Replication: Multi-target replication for redundancy
  • Recovery: Automated recovery procedures with status tracking
  • Event Callbacks: Subscribe to backup events for custom handling
  • Thread-Safe Operations: All operations are thread-safe for concurrent access

BackupManager

Central manager for all backup and recovery operations.

Location: novacoder/backup/manager.py

Key Features:

  • Orchestrates scheduling, verification, storage, and recovery
  • Backup job management
  • Overall statistics and configuration
  • Maintenance operations (cleanup)

BackupScheduler

Automated backup scheduling.

Location: novacoder/backup/scheduler.py

Key Features:

  • Multiple schedule types (Immediate, Interval, Cron, Daily, Weekly, Monthly)
  • Schedule management (add, remove, update, enable/disable)
  • Due schedule detection
  • Schedule statistics

BackupVerifier

Backup verification and integrity checking.

Location: novacoder/backup/verification.py

Key Features:

  • Checksum calculation (SHA256, MD5, SHA1)
  • Backup verification with expected checksums
  • Verification result tracking
  • Verification statistics
  • Old verification cleanup

BackupStorage

Multi-backend storage management.

Location: novacoder/backup/storage.py

Key Features:

  • Multiple storage backends (Local, S3, Azure, GCS)
  • Storage location management
  • Backup storing and retrieval
  • Backup deletion and listing
  • Storage statistics

RecoveryManager

Disaster recovery planning and execution.

Location: novacoder/backup/recovery.py

Key Features:

  • Recovery plan management
  • Recovery step definition
  • Recovery execution tracking
  • Recovery statistics

API Endpoints

List Backup Jobs

GET /api/backup/jobs

Returns all backup jobs.

Get Backup Statistics

GET /api/backup/statistics

Returns backup system statistics.

Usage Example

Advanced Backup System

from novacoder.backup import AdvancedBackup, BackupType, BackupStatus
from novacoder.backup.advanced import BackupConfig

# Create advanced backup manager
backup = AdvancedBackup()
backup.start()

# Add backup configuration
config = BackupConfig(
    source_path='~/project',
    destination_path='/backup',
    backup_type=BackupType.FULL,
    schedule_interval=3600.0,  # 1 hour
    retention_count=7,
    enable_verification=True,
    enable_replication=True
)
backup.add_backup_config(config)

# Create backup
backup_result = backup.create_backup(config.backup_id)
print(f"Backup status: {backup_result.status}")
print(f"Backup size: {backup_result.size_bytes}")

# Verify backup
verified = backup.recover_backup(backup_result.backup_id)
print(f"Backup verified: {verified}")

# Replicate backup
replicated = backup.create_backup(backup_result.backup_id, '/backup/replica')
print(f"Backup replicated: {replicated}")

# Get backup statistics
stats = backup.get_backup_stats()
print(f"Total backups: {stats['total_backups']}")
print(f"Total size: {stats['total_size_bytes']}")

backup.stop()

Traditional Backup Manager

from novacoder.backup.manager import BackupManager, BackupConfig, BackupJob
from novacoder.backup.scheduler import BackupSchedule, ScheduleType
from novacoder.backup.verification import BackupVerifier
from novacoder.backup.storage import BackupLocation, StorageBackend
from novacoder.backup.recovery import RecoveryPlan, RecoveryStep

# Create manager
config = BackupConfig()
manager = BackupManager(config)

# Create backup schedule
schedule = BackupSchedule(
    name="daily-backup",
    schedule_type=ScheduleType.DAILY,
    schedule_value="02:00"
)
manager.add_backup_schedule(schedule)

# Create backup job
job = BackupJob(
    name="project-backup",
    source_path="~/project",
    schedule_id=schedule.schedule_id,
    retention_days=30
)
manager.create_backup_job(job)

# Execute backup
manager.execute_backup_job(job.job_id)

# Verify backup
verifier = manager.get_verifier()
result = verifier.verify_backup(
    backup_id=job.job_id,
    backup_path=Path("/backup/project_20240119_020000")
)

# Create recovery plan
plan = RecoveryPlan(
    name="disaster-recovery",
    rto=3600.0,  # 1 hour recovery time objective
    rpo=3600.0   # 1 hour recovery point objective
)
plan.add_step(RecoveryStep(name="Restore Database", order=1))
plan.add_step(RecoveryStep(name="Restore Files", order=2))
manager.create_recovery_plan(plan)

Integration

Manager: BackupManager in novacoder/backup/manager.py

The backup and disaster recovery system is integrated into the NovaApplication and accessible via:

  • Direct instantiation of BackupManager
  • API endpoints for backup jobs and statistics
  • Integration with existing storage backends

Schedule Types

Immediate

Execute backup immediately.

Interval

Execute backup at regular intervals (seconds).

Cron

Execute backup using cron expression.

Daily

Execute backup daily at specified time.

Weekly

Execute backup weekly on specified day and time.

Monthly

Execute backup monthly on specified day and time.

Storage Backends

Local Storage

BackupLocation(
    name="local",
    backend=StorageBackend.LOCAL,
    path="/backup"
)

S3 Storage

BackupLocation(
    name="s3",
    backend=StorageBackend.S3,
    path="s3://my-bucket/backups",
    credentials={"access_key": "...", "secret_key": "..."}
)

Azure Storage

BackupLocation(
    name="azure",
    backend=StorageBackend.AZURE,
    path="azure://my-container/backups",
    credentials={"connection_string": "..."}
)

GCS Storage

BackupLocation(
    name="gcs",
    backend=StorageBackend.GCS,
    path="gs://my-bucket/backups",
    credentials={"credentials_path": "..."}
)

Recovery Planning

Recovery Steps

RecoveryStep(
    name="Restore Database",
    description="Restore database from backup",
    order=1,
    required=True,
    estimated_duration=300.0
)

Recovery Objectives

  • RTO (Recovery Time Objective): Maximum acceptable downtime
  • RPO (Recovery Point Objective): Maximum acceptable data loss

Benefits

  • Data Protection: Automated backup scheduling and verification
  • Business Continuity: Disaster recovery planning ensures quick recovery
  • Compliance: Meet data retention requirements
  • Reduced Risk: Multi-backend storage prevents single point of failure
  • Integrity Verification: Checksum verification ensures backup integrity
  • Flexible Storage: Support for multiple storage backends

Configuration

Backup settings can be configured through the application configuration:

{
  "backup": {
    "enable_scheduling": true,
    "enable_verification": true,
    "enable_storage": true,
    "enable_recovery": true,
    "default_retention_days": 30,
    "auto_cleanup": true,
    "backup_directory": "~/.novacoder/backups"
  }
}

See Also

  • Kernel Backup/Recovery - Kernel-level backup features
  • Memory Backup/Recovery - Memory system backup
  • Deployment - Deployment system

Source: wiki/backup-disaster-recovery.md · rendered 2026-11-10