swarm / companies/starter/work/project/docs/rollback_v2.3.md

raw file 1884 bytes
# Rollback Plan: v2.3 Deploy

## 1. Pre-Deploy: Verified Backup
Before executing the v2.3 deploy, a verified backup of the Postgres database **must** be created.

1.  **Create Backup:**
    ```bash
    pg_dump -Fc -f /backups/ferrite_v2.2_pre_deploy.dump
2.  **Verify Backup Integrity:**
    Check the file size and verify the checksum to ensure the backup is complete and not corrupted.
    ```bash
    sha256sum /backups/ferrite_v2.2_pre_deploy.dump
    *Note: Do not proceed with the deploy if the backup file is missing or the checksum verification fails.*

## 2. Rollback Execution
If the v2.3 deploy fails (e.g., migration errors, application crashes), execute the following steps immediately.

1.  **Stop the Sync Engine:**
    ```bash
    systemctl stop ferrite-sync
2.  **Restore Database:**
    Restore the verified backup created in Step 1.
    ```bash
    pg_restore -c -d ferrite_db /backups/ferrite_v2.2_pre_deploy.dump
3.  **Revert Application:**
    Deploy the previous version (v2.2) of the sync engine binary.
    ```bash
    # Example: Replace the v2.3 binary with the v2.2 binary
    cp /opt/ferrite/bin/sync_engine_v2.2 /opt/ferrite/bin/sync_engine
4.  **Start the Sync Engine:**
    ```bash
    systemctl start ferrite-sync

## 3. Post-Rollback Verification
After rollback, verify the system state.

1.  **Check Service Status:**
    ```bash
    systemctl status ferrite-sync
2.  **Check Database Consistency:**
    Ensure the database is accepting connections and the expected tables exist.
    ```bash
    psql -d ferrite_db -c "SELECT 1;"
3.  **Monitor Logs:**
    Check `/var/log/ferrite/sync.log` for any error messages post-restore.

## 4. Escalation
If the rollback fails or data inconsistency is detected after restore, **DO NOT** attempt further automated fixes.
*   **Contact:** Marcus Chen (Tech Lead)
*   **Action:** Manual DBA intervention required.