Backup Management System

Comprehensive Data Protection for Your ERP System

Overview

The CNPERP Backup Management System provides comprehensive data protection with both absolute and incremental backup capabilities, automated scheduling, and secure restore functionality.

Key Features

Backup Types

  • Absolute Backups: Complete system snapshots
  • Incremental Backups: Only changes since last backup
  • Scheduled Backups: Automated with configurable frequency

Backup Components

  • Full PostgreSQL database dump
  • Application files and configurations
  • SHA256 hash verification
  • Automatic file compression

Management Features

  • Complete backup history
  • Real-time status monitoring
  • Filter by type, status, date range
  • Storage usage tracking

Restore Capabilities

  • Selective restore (database, files, or both)
  • Multiple confirmation steps
  • Complete restore history tracking
  • Safety checks before restore

Backup Storage Structure

backups/ +-- absolute/ # Full system backups ¦ +-- backup_absolute_20240101_120000_uuid.sql ¦ +-- files_absolute_20240101_120000_uuid.zip ¦ +-- uuid_backup_metadata.json +-- incremental/ # Incremental backups ¦ +-- backup_incremental_20240101_120000_uuid.sql ¦ +-- files_incremental_20240101_120000_uuid.zip ¦ +-- uuid_backup_metadata.json +-- logs/ # Backup operation logs

Creating Manual Backups

Via Web Interface

  1. Navigate to Admin Panel ? Backup Management
  2. Click "Create Backup" button
  3. Select backup type (Absolute or Incremental)
  4. Add optional description
  5. Choose backup options (include files, specific tables)
  6. Click "Create Backup"

Via API

# Create absolute backup curl -X POST "http://localhost:8000/api/v1/backup/create" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_TOKEN" \ -d '{ "backup_type": "absolute", "description": "Weekly full backup", "include_files": true }' # Create incremental backup curl -X POST "http://localhost:8000/api/v1/backup/create" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_TOKEN" \ -d '{ "backup_type": "incremental", "description": "Daily incremental backup", "include_files": false }'

Scheduling Automated Backups

Via Web Interface

  1. Go to Backup Management ? Scheduled Backups tab
  2. Click "Schedule Backup" button
  3. Configure:
    • Backup Type: Absolute or Incremental
    • Frequency: Daily, Weekly, or Monthly
    • Time: When to run (24-hour format)
    • Description: Optional description
  4. Click "Schedule Backup"

Via API

# Schedule daily backup at 2 AM curl -X POST "http://localhost:8000/api/v1/backup/schedule" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_TOKEN" \ -d '{ "backup_type": "incremental", "frequency": "daily", "time": "02:00", "description": "Daily incremental backup", "include_files": true }'

Restoring from Backup

Warning

Restoring from backup will overwrite existing data. Always confirm you have selected the correct backup before proceeding.

Via Web Interface

  1. Go to Backup Management ? Restore tab
  2. Select a completed backup from the list
  3. Click "Restore" button
  4. Choose restore options:
    • Restore Database: Restore all database data
    • Restore Files: Restore application files
  5. Confirm the restore operation
  6. Wait for restore completion

Via API

# Restore from backup curl -X POST "http://localhost:8000/api/v1/backup/BACKUP_ID/restore" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_TOKEN" \ -d '{ "restore_database": true, "restore_files": false, "confirm_restore": true }'

Best Practices

Backup Schedule
  • Daily: Incremental backups
  • Weekly: Full absolute backups
  • Monthly: Long-term archival backups
Storage Management
  • Monitor available disk space
  • Set retention policies (e.g., 30 days)
  • Archive old backups to external storage
Security
  • Restrict backup access to authorized users
  • Verify backup integrity regularly
  • Test restore procedures quarterly
Verification
  • Check backup completion status daily
  • Verify file sizes are reasonable
  • Test restore on non-production systems

Database Schema

Backup Records Table

CREATE TABLE backups ( id VARCHAR PRIMARY KEY, backup_type VARCHAR NOT NULL, -- 'absolute', 'incremental', 'restore' description TEXT, status VARCHAR NOT NULL, -- 'in_progress', 'completed', 'failed' file_path VARCHAR, file_size INTEGER, file_hash VARCHAR, -- SHA256 hash for integrity metadata JSONB, -- Backup metadata error_message TEXT, created_at TIMESTAMP DEFAULT NOW(), created_by VARCHAR NOT NULL, completed_at TIMESTAMP );

Backup Schedules Table

CREATE TABLE backup_schedules ( id VARCHAR PRIMARY KEY, backup_type VARCHAR NOT NULL, frequency VARCHAR NOT NULL, -- 'daily', 'weekly', 'monthly' time VARCHAR NOT NULL, -- 'HH:MM' format include_files BOOLEAN DEFAULT TRUE, description TEXT, is_active BOOLEAN DEFAULT TRUE, last_run TIMESTAMP, next_run TIMESTAMP, created_at TIMESTAMP DEFAULT NOW(), created_by VARCHAR NOT NULL );