# DB Backup Implementation Plan (Cloud Functions)

> **Goal**: Implement a scheduled database backup system using Firebase Cloud Functions (Blaze Plan) to export Firestore data to Google Cloud Storage.

## User Review Required
> [!IMPORTANT]
> **Prerequisites**:
> 1.  **Blaze Plan**: Firebase Project must be on the Blaze (Pay-as-you-go) plan.
> 2.  **App Engine**: App Engine must be enabled in the project.
> 3.  **Permissions**: The "Default App Engine Service Account" needs `Cloud Datastore Import/Export Admin` role.

## Proposed Changes

### Backend (Cloud Functions)
#### [NEW] [functions/src/backup.ts](file:///functions/src/backup.ts)
- **Function**: `scheduledFirestoreExport`
- **Trigger**: Pub/Sub Schedule (Every 24 hours at 04:00 KST).
- **Logic**:
    - Uses `fireStore.admin.v1.FirestoreAdminClient` to trigger an export.
    - Exports all collections to a GCS bucket.

#### [MODIFY] [functions/src/index.ts](file:///functions/src/index.ts)
- Export the new `scheduledFirestoreExport` function.

## Verification Plan

### Automated Verification
- Deploy functions: `firebase deploy --only functions`
- Check Logs: Monitor Firebase Console > Functions > Logs.
- Verify GCS: Check the configured bucket for the export folder.

### Manual Verification
- Manually trigger the function via GCP Console (Cloud Scheduler) to verify immediate execution.
