LogoContainerPub

Backup Workflows and Diagrams

Visual guides and workflows for backup and disaster recovery operations

Backup Workflows and Diagrams#

Visual guides and step-by-step workflows for backup and disaster recovery operations in ContainerPub.

🔄 Backup Workflows#

Complete Backup Workflow#

┌─────────────────────────────────────────────────────────┐
│                   START: Backup Request                  │
└─────────────────────┬───────────────────────────────────┘
                      │
                      ▼
┌─────────────────────────────────────────────────────────┐
│              Pre-Backup Validation                       │
│  • Check container status                                │
│  • Verify disk space                                     │
│  • Validate credentials                                  │
└─────────────────────┬───────────────────────────────────┘
                      │
                      ▼
┌─────────────────────────────────────────────────────────┐
│              Database Backup Phase                       │
│  1. Connect to PostgreSQL container                      │
│  2. Dump main database (dart_cloud)                      │
│  3. Dump functions database (functions_db)               │
│  4. Compress with gzip                                   │
│  5. Create combined archive                              │
└─────────────────────┬───────────────────────────────────┘
                      │
                      ▼
┌─────────────────────────────────────────────────────────┐
│              Volume Backup Phase                         │
│  1. Create temporary Alpine container                    │
│  2. Mount PostgreSQL volume (read-only)                  │
│  3. Create tar.gz archive                                │
│  4. Mount functions volume (read-only)                   │
│  5. Create tar.gz archive                                │
│  6. Create combined volume archive                       │
└─────────────────────┬───────────────────────────────────┘
                      │
                      ▼
┌─────────────────────────────────────────────────────────┐
│              Post-Backup Tasks                           │
│  • Generate metadata files                               │
│  • Verify backup integrity                               │
│  • Calculate checksums                                   │
│  • Clean old backups (retention policy)                  │
└─────────────────────┬───────────────────────────────────┘
                      │
                      ▼
┌─────────────────────────────────────────────────────────┐
│         Replication Phase (if enabled)                   │
│  • Copy to local destination                             │
│  • Sync to remote server (rsync)                         │
│  • Upload to S3 bucket                                   │
│  • Execute custom replication                            │
└─────────────────────┬───────────────────────────────────┘
                      │
                      ▼
┌─────────────────────────────────────────────────────────┐
│              Notification & Logging                      │
│  • Log backup completion                                 │
│  • Send notifications (if configured)                    │
│  • Update backup manifest                                │
└─────────────────────┬───────────────────────────────────┘
                      │
                      ▼
┌─────────────────────────────────────────────────────────┐
│                   END: Backup Complete                   │
└─────────────────────────────────────────────────────────┘

Restore Workflow#

┌─────────────────────────────────────────────────────────┐
│                START: Restore Request                    │
└─────────────────────┬───────────────────────────────────┘
                      │
                      ▼
┌─────────────────────────────────────────────────────────┐
│              Pre-Restore Validation                      │
│  • Verify backup file exists                             │
│  • Check backup integrity (tar -tzf)                     │
│  • Validate backup metadata                              │
│  • Confirm with user (unless -y flag)                    │
└─────────────────────┬───────────────────────────────────┘
                      │
                      ▼
┌─────────────────────────────────────────────────────────┐
│              Service Shutdown                            │
│  • Stop backend container                                │
│  • Keep PostgreSQL running (for DB restore)              │
│  • Wait for graceful shutdown                            │
└─────────────────────┬───────────────────────────────────┘
                      │
                      ▼
┌─────────────────────────────────────────────────────────┐
│         Volume Restore Phase (if requested)              │
│  1. Extract volume backup archive                        │
│  2. Create temporary container                           │
│  3. Mount target volume                                  │
│  4. Clear existing volume data                           │
│  5. Copy backup data to volume                           │
│  6. Verify volume restore                                │
└─────────────────────┬───────────────────────────────────┘
                      │
                      ▼
┌─────────────────────────────────────────────────────────┐
│              Service Startup                             │
│  • Start PostgreSQL container                            │
│  • Wait for database health check                        │
│  • Verify database connectivity                          │
└─────────────────────┬───────────────────────────────────┘
                      │
                      ▼
┌─────────────────────────────────────────────────────────┐
│         Database Restore Phase (if requested)            │
│  1. Extract database backup archive                      │
│  2. Decompress SQL dumps                                 │
│  3. Execute main database restore                        │
│  4. Execute functions database restore                   │
│  5. Verify database integrity                            │
└─────────────────────┬───────────────────────────────────┘
                      │
                      ▼
┌─────────────────────────────────────────────────────────┐
│              Full Service Restart                        │
│  • Start backend container                               │
│  • Wait for health checks                                │
│  • Verify all services running                           │
└─────────────────────┬───────────────────────────────────┘
                      │
                      ▼
┌─────────────────────────────────────────────────────────┐
│              Post-Restore Validation                     │
│  • Test database connections                             │
│  • Verify data integrity                                 │
│  • Check application functionality                       │
│  • Log restore completion                                │
└─────────────────────┬───────────────────────────────────┘
                      │
                      ▼
┌─────────────────────────────────────────────────────────┐
│                 END: Restore Complete                    │
└─────────────────────────────────────────────────────────┘

🔁 Replication Workflows#

Local Replication#

┌──────────────┐
│ Backup Files │
└──────┬───────┘
       │
       ▼
┌──────────────────┐
│ Create Temp Copy │
└──────┬───────────┘
       │
       ▼
┌──────────────────┐
│ Copy to Local    │
│ Destination      │
└──────┬───────────┘
       │
       ▼
┌──────────────────┐
│ Verify Copy      │
└──────┬───────────┘
       │
       ▼
┌──────────────────┐
│ Clean Temp Files │
└──────────────────┘

Remote Replication (Rsync)#

┌──────────────┐
│ Backup Files │
└──────┬───────┘
       │
       ▼
┌──────────────────┐
│ Test SSH         │
│ Connection       │
└──────┬───────────┘
       │
       ▼
┌──────────────────┐
│ Rsync Transfer   │
│ (incremental)    │
└──────┬───────────┘
       │
       ▼
┌──────────────────┐
│ Verify Transfer  │
│ (checksums)      │
└──────┬───────────┘
       │
       ▼
┌──────────────────┐
│ Update Log       │
└──────────────────┘

S3 Replication#

┌──────────────┐
│ Backup Files │
└──────┬───────┘
       │
       ▼
┌──────────────────┐
│ Verify AWS CLI   │
│ Configuration    │
└──────┬───────────┘
       │
       ▼
┌──────────────────┐
│ Upload to S3     │
│ (multipart)      │
└──────┬───────────┘
       │
       ▼
┌──────────────────┐
│ Verify Upload    │
│ (ETag check)     │
└──────┬───────────┘
       │
       ▼
┌──────────────────┐
│ Set Storage      │
│ Class & Metadata │
└──────────────────┘

🚨 Disaster Recovery Workflow#

Complete System Recovery#

┌─────────────────────────────────────────────────────────┐
│              DISASTER DETECTED                           │
│  • System failure                                        │
│  • Data corruption                                       │
│  • Hardware failure                                      │
└─────────────────────┬───────────────────────────────────┘
                      │
                      ▼
┌─────────────────────────────────────────────────────────┐
│              Assessment Phase                            │
│  1. Identify scope of failure                            │
│  2. Determine last known good backup                     │
│  3. Estimate recovery time                               │
│  4. Notify stakeholders                                  │
└─────────────────────┬───────────────────────────────────┘
                      │
                      ▼
┌─────────────────────────────────────────────────────────┐
│              Preparation Phase                           │
│  1. Provision new infrastructure (if needed)             │
│  2. Install Docker and dependencies                      │
│  3. Clone ContainerPub repository                        │
│  4. Configure environment variables                      │
└─────────────────────┬───────────────────────────────────┘
                      │
                      ▼
┌─────────────────────────────────────────────────────────┐
│              Volume Recovery                             │
│  1. Transfer backup files to new system                  │
│  2. Create Docker volumes                                │
│  3. Restore PostgreSQL volume                            │
│  4. Restore functions volume                             │
│  5. Verify volume integrity                              │
└─────────────────────┬───────────────────────────────────┘
                      │
                      ▼
┌─────────────────────────────────────────────────────────┐
│              Service Initialization                      │
│  1. Start PostgreSQL container                           │
│  2. Wait for database ready                              │
│  3. Verify database connectivity                         │
└─────────────────────┬───────────────────────────────────┘
                      │
                      ▼
┌─────────────────────────────────────────────────────────┐
│              Database Recovery                           │
│  1. Restore main database                                │
│  2. Restore functions database                           │
│  3. Verify schema integrity                              │
│  4. Check data consistency                               │
└─────────────────────┬───────────────────────────────────┘
                      │
                      ▼
┌─────────────────────────────────────────────────────────┐
│              Application Recovery                        │
│  1. Start backend container                              │
│  2. Verify health endpoints                              │
│  3. Test function execution                              │
│  4. Verify API endpoints                                 │
└─────────────────────┬───────────────────────────────────┘
                      │
                      ▼
┌─────────────────────────────────────────────────────────┐
│              Validation Phase                            │
│  1. Run smoke tests                                      │
│  2. Verify data integrity                                │
│  3. Test critical workflows                              │
│  4. Monitor system metrics                               │
└─────────────────────┬───────────────────────────────────┘
                      │
                      ▼
┌─────────────────────────────────────────────────────────┐
│              Post-Recovery                               │
│  1. Update DNS/load balancers                            │
│  2. Enable monitoring and alerts                         │
│  3. Document recovery process                            │
│  4. Conduct post-mortem                                  │
│  5. Update disaster recovery plan                        │
└─────────────────────┬───────────────────────────────────┘
                      │
                      ▼
┌─────────────────────────────────────────────────────────┐
│              SYSTEM RECOVERED                            │
└─────────────────────────────────────────────────────────┘

📊 Decision Trees#

Backup Type Selection#

                    Need Backup?
                         │
                         ▼
              ┌──────────┴──────────┐
              │                     │
         Full System            Partial
              │                     │
              ▼                     ▼
      backup-all.sh      ┌──────────┴──────────┐
                         │                     │
                    Database                Volume
                         │                     │
                         ▼                     ▼
              backup-database.sh    backup-volumes.sh

Restore Strategy Selection#

                  What to Restore?
                         │
                         ▼
              ┌──────────┴──────────┐
              │                     │
         Everything             Selective
              │                     │
              ▼                     ▼
      1. Volumes First    ┌────────┴────────┐
      2. Start Services   │                 │
      3. Databases     Database          Volume
                           │                 │
                           ▼                 ▼
                  restore-database.sh  restore-volumes.sh

Replication Type Selection#

                Where to Replicate?
                         │
                         ▼
         ┌───────────────┼───────────────┐
         │               │               │
      Same Host      Remote Host     Cloud
         │               │               │
         ▼               ▼               ▼
    Local Copy      Rsync/SCP         S3/R2
         │               │               │
         ▼               ▼               ▼
    -t local        -t rsync         -t s3

🔄 Automated Backup Flow#

Cron-Based Backup Service#

┌─────────────────────────────────────────────────────────┐
│              Cron Scheduler (Container)                  │
└─────────────────────┬───────────────────────────────────┘
                      │
                      ▼ (Schedule: 0 2 * * *)
┌─────────────────────────────────────────────────────────┐
│              Trigger Backup Script                       │
└─────────────────────┬───────────────────────────────────┘
                      │
                      ▼
┌─────────────────────────────────────────────────────────┐
│              Execute backup-all.sh                       │
│  • Database backup                                       │
│  • Volume backup                                         │
│  • Create archives                                       │
└─────────────────────┬───────────────────────────────────┘
                      │
                      ▼
┌─────────────────────────────────────────────────────────┐
│         Check REPLICATION_ENABLED                        │
└─────────────────────┬───────────────────────────────────┘
                      │
              ┌───────┴───────┐
              │               │
           true            false
              │               │
              ▼               ▼
┌──────────────────┐   ┌──────────────┐
│ Execute          │   │ Skip         │
│ Replication      │   │ Replication  │
└────────┬─────────┘   └──────┬───────┘
         │                    │
         └────────┬───────────┘
                  │
                  ▼
┌─────────────────────────────────────────────────────────┐
│              Log Results                                 │
│  • Backup status                                         │
│  • Replication status                                    │
│  • Errors (if any)                                       │
└─────────────────────┬───────────────────────────────────┘
                      │
                      ▼
┌─────────────────────────────────────────────────────────┐
│         Send Notifications (if configured)               │
└─────────────────────┬───────────────────────────────────┘
                      │
                      ▼
┌─────────────────────────────────────────────────────────┐
│              Wait for Next Schedule                      │
└─────────────────────────────────────────────────────────┘

📈 Backup Lifecycle#

┌──────────────┐
│ Backup       │
│ Created      │
└──────┬───────┘
       │
       ▼
┌──────────────────┐
│ Active Backup    │
│ (0-7 days)       │
└──────┬───────────┘
       │
       ▼
┌──────────────────┐
│ Retention Check  │
│ (Daily)          │
└──────┬───────────┘
       │
       ▼
┌──────────────────┐
│ Age > Retention? │
└──────┬───────────┘
       │
   ┌───┴───┐
   │       │
  Yes     No
   │       │
   ▼       ▼
┌──────┐ ┌──────┐
│Delete│ │Keep  │
└──────┘ └──────┘

🎯 Best Practice Workflows#

Weekly Backup Test#

Monday:
  └─ Create test backup
       └─ backup-all.sh

Wednesday:
  └─ Restore to staging
       ├─ Stop staging services
       ├─ Restore volumes
       ├─ Restore databases
       └─ Verify functionality

Friday:
  └─ Document results
       ├─ Record restore time
       ├─ Note any issues
       └─ Update procedures

Monthly Disaster Recovery Drill#

Week 1:
  └─ Plan drill scenario
       ├─ Define failure type
       ├─ Identify team members
       └─ Schedule drill time

Week 2:
  └─ Execute drill
       ├─ Simulate disaster
       ├─ Execute recovery
       ├─ Time each phase
       └─ Document issues

Week 3:
  └─ Review and improve
       ├─ Analyze results
       ├─ Update procedures
       ├─ Train team
       └─ Update documentation

Week 4:
  └─ Verify improvements
       └─ Test updated procedures

Last Updated: November 2025
Version: 1.0.0