Export and Backup

Create comprehensive backups of your feature flags and configuration

Export Overview

FlagFlow's export functionality allows you to create complete backups of your feature flag configuration, including schemas, values, and metadata. These exports serve multiple purposes: creating backups, migrating between environments, and maintaining version control of your flag configurations.

Complete Data Export: The export includes all flag definitions, schemas, current values, default values, and type-specific constraints in a single JSON file.

What Gets Exported

When you export your FlagFlow configuration, the system creates a comprehensive snapshot containing:

Flag Definitions

  • All flag names and hierarchical structure
  • Flag types (BOOLEAN, INTEGER, STRING, etc.)
  • Flag descriptions and documentation
  • Default values for each flag

Schema Information

  • Type-specific constraints and validation rules
  • Enum values and available options
  • Min/max values for numeric flags
  • String length limits and regex patterns

Current Values

  • Active flag values (if set)
  • Value existence status
  • AB-test configurations
  • Tag selections and arrays

Metadata

  • Environment identifier
  • FlagFlow version information
  • Export timestamp
  • File format version

How to Export

Web Interface Export

The easiest way to create an export is through the FlagFlow web interface:

  1. Navigate to the Migration page in your FlagFlow instance
  2. Locate the Export section at the top of the page
  3. Click the Download Export button
  4. Your browser will download a JSON file with the current timestamp

API Export

You can also export programmatically using the REST API:

Note: Export functionality is available without authentication - anyone with network access to your FlagFlow instance can download configuration exports.

API Export Commands
# Direct download via curl
curl -O http://localhost:3000/migration/export

# Save to specific filename
curl -o my-backup-$(date +%Y%m%d).json \
     http://localhost:3000/migration/export

Automated Backup Scripts

Automated Backup Script
#!/bin/bash
# automated-backup.sh

FLAGFLOW_URL="http://localhost:3000"
BACKUP_DIR="/path/to/backups"
DATE=$(date +%Y%m%d-%H%M%S)
ENVIRONMENT="production"

# Create backup directory if it doesn't exist
mkdir -p "$BACKUP_DIR"

# Download backup with timestamp
FILENAME="flagflow_backup_{ENVIRONMENT}_{DATE}.json"
curl -s "$FLAGFLOW_URL/migration/export" -o "$BACKUP_DIR/$FILENAME"

if [ $? -eq 0 ]; then
    echo "✅ Backup created successfully: $FILENAME"
    # Optional: Clean up old backups (keep last 30 days)
    find "$BACKUP_DIR" -name "flagflow_backup_*.json" -mtime +30 -delete
else
    echo "❌ Backup failed!"
    exit 1
fi

Export File Format

FlagFlow exports create JSON files with a standardized structure that includes all necessary information for backup and migration purposes:

Export File Structure
{
  "environment": "production",
  "version": "1.0.0",
  "createdAt": "2024-08-10T14:30:25.123Z",
  "flags": {
    "enable_new_feature": {
      "description": "Enable the new dashboard feature",
      "type": "BOOLEAN",
      "defaultValue": false,
      "valueExists": true,
      "value": true
    },
    "max_retries": {
      "description": "Maximum number of retry attempts",
      "type": "INTEGER", 
      "defaultValue": 3,
      "valueExists": true,
      "value": 5,
      "minValue": 1,
      "maxValue": 10
    },
    "theme_selection": {
      "description": "UI theme options",
      "type": "ENUM",
      "defaultValue": "auto",
      "valueExists": false,
      "enumValues": ["light", "dark", "auto"]
    },
    "enabled_features": {
      "description": "List of enabled feature modules",
      "type": "TAG",
      "defaultValue": ["core"],
      "valueExists": true,
      "value": ["core", "analytics", "notifications"],
      "enumValues": ["core", "analytics", "notifications", "chat"],
      "minCount": 1,
      "maxCount": 4
    },
    "ab_test_experiment": {
      "description": "A/B test for new checkout flow",
      "type": "AB-TEST",
      "defaultValue": "A",
      "valueExists": true,
      "value": "B",
      "chancePercentB": 25.0
    }
  }
}

File Naming Convention

Export files follow a consistent naming pattern that includes environment and timestamp information:

File Naming Examples
# Naming pattern
flagflow_migration_{ENVIRONMENT}_{YYYYMMDD-HHMMSS}.json

# Examples
flagflow_migration_production_20240810-143025.json
flagflow_migration_staging_20240810-143025.json
flagflow_migration_development_20240810-143025.json

Flag Type Export Details

Different flag types include specific properties in the export file to preserve all configuration details:

Flag TypeAdditional PropertiesExample Value
BOOLEANNone (simple true/false)true
INTEGERminValue, maxValue42
STRINGmaxLength, regexPattern"hello world"
ENUMenumValues array"option1"
TAGenumValues, minCount, maxCount["tag1", "tag2"]
AB-TESTchancePercentB"A" or "B"

Backup Strategies

Regular Automated Backups

Set up automated backups to ensure you always have recent copies of your flag configurations:

Cron Backup Examples
# Add to crontab for daily backups at 2 AM
0 2 * * * /path/to/automated-backup.sh

# Weekly backups with rotation
0 2 * * 0 /path/to/weekly-backup.sh

# Pre-deployment backups
# Add to your CI/CD pipeline before deployments
curl -o "backup-pre-deploy-$(date +%Y%m%d-%H%M%S).json" \
     "$FLAGFLOW_URL/migration/export"

Environment-Specific Backup Plans

  • Production: Daily automated backups with 30-day retention
  • Staging: Weekly backups before major testing cycles
  • Development: Manual backups before experimental changes

Backup Verification

Backup Verification Script
#!/bin/bash
# verify-backup.sh - Verify backup file integrity

BACKUP_FILE=$1

if [ ! -f "$BACKUP_FILE" ]; then
    echo "❌ Backup file not found: $BACKUP_FILE"
    exit 1
fi

# Check if file is valid JSON
if jq empty "$BACKUP_FILE" 2>/dev/null; then
    echo "✅ Valid JSON format"
else
    echo "❌ Invalid JSON format"
    exit 1
fi

# Check required fields
ENVIRONMENT=$(jq -r '.environment' "$BACKUP_FILE")
VERSION=$(jq -r '.version' "$BACKUP_FILE")
FLAG_COUNT=$(jq '.flags | length' "$BACKUP_FILE")

echo "📊 Backup Summary:"
echo "   Environment: $ENVIRONMENT"
echo "   Version: $VERSION"
echo "   Flag Count: $FLAG_COUNT"

if [ "$FLAG_COUNT" -gt 0 ]; then
    echo "✅ Backup verification successful"
else
    echo "❌ No flags found in backup"
    exit 1
fi

Storage and Security

Storage Recommendations

  • Local Storage: Keep recent backups on the same server for quick recovery
  • Remote Storage: Upload to cloud storage (AWS S3, Google Cloud, etc.) for disaster recovery
  • Version Control: Consider storing exports in Git repositories for change tracking
  • Multiple Locations: Store copies in different geographic locations

Security Considerations

Important Security Notes

  • Access Control: Limit who can create and access backup files
  • Encryption: Encrypt backup files if they contain sensitive configuration
  • Network Security: Use HTTPS for API-based exports
  • Audit Trail: Log all export operations for security auditing
Backup Encryption Example
# Encrypt backup files
gpg --cipher-algo AES256 --compress-algo 1 --symmetric \
    --output backup.json.gpg backup.json

# Upload to secure storage
aws s3 cp backup.json.gpg s3://my-flagflow-backups/ \
    --server-side-encryption AES256

# Decrypt when needed
gpg --decrypt backup.json.gpg > restored-backup.json

Troubleshooting

Export Download Fails

  • Check that FlagFlow service is running and accessible
  • Verify network connectivity to the FlagFlow instance
  • Ensure you have proper permissions for export operations
  • Check server logs for any etcd connectivity issues

Large Export Files

  • Export files grow with the number of flags and complexity
  • Consider implementing flag archiving for unused flags
  • Use compression when storing large backup files
  • Monitor disk space for automated backup directories

Corrupted Export Files

  • Always verify JSON validity after downloading exports
  • Use checksums or file integrity checks for important backups
  • Keep multiple backup versions to avoid single points of failure
  • Test backup restoration regularly in non-production environments

Next Steps

After creating your backup export files, you can use them for:

  • Environment Migration: Transfer flag configurations between different FlagFlow environments
  • Disaster Recovery: Restore your flag configuration after system failures
  • Configuration Versioning: Track changes to your flag setup over time
  • Testing: Create isolated test environments with production flag configurations

Learn more about using these exports in the Migration and Restore documentation.

© 2025 FlagFlow All Rights Reserved. llms.txt