Skip to main content

Getting Started Guide

Quick Start

Get Terraback running in under 5 minutes with this quick start guide.

Prerequisites Check

# Ensure you have Terraform installed
terraform --version

# Verify Terraback installation
terraback --version

# Check system requirements
terraback doctor

Your First Backup

Step 1: Navigate to Your Terraform Project

cd /path/to/your/terraform/project

# Verify you're in the right directory
ls -la *.tf

Step 2: Initialize Terraback

# Initialize Terraback in the current directory
terraback init

# You'll see:
✅ Terraback initialized successfully
📁 Project: my-infrastructure
🔧 Terraform version: 1.5.7
💾 State file detected: terraform.tfstate

Step 3: Create Your First Backup

# Create a manual backup
terraback backup create --name "initial-backup"

# Output:
🔄 Creating backup...
📦 Compressing state files...
🔐 Encrypting backup...
☁️ Uploading to storage...
✅ Backup created successfully
📍 Backup ID: backup_20240115_143022
📏 Size: 2.4 MB
🏷️ Name: initial-backup

Step 4: Verify the Backup

# List all backups
terraback backup list

# Show backup details
terraback backup show backup_20240115_143022

Basic Workflow

Daily Operations

Morning Routine

# Check backup status
terraback status

# Review any drift detected overnight
terraback drift show

# Ensure automated backups are running
terraback backup schedule status

Before Making Changes

# Create a checkpoint before terraform apply
terraback checkpoint create --name "before-scaling-change"

# Make your Terraform changes
terraform plan
terraform apply

# Verify backup was created
terraback backup list --limit 1

After Incidents

# List recent backups
terraback backup list --since "2 hours ago"

# Preview what would be restored
terraback restore preview backup_20240115_143022

# Restore if needed
terraback restore apply backup_20240115_143022

Setting Up Automation

Enable Automatic Backups

# Configure automatic backups every hour
terraback backup schedule create \
--interval 1h \
--retention 30d \
--name "hourly-auto"

# Verify schedule
terraback backup schedule list

Configure Drift Detection

# Enable drift detection
terraback drift enable

# Set check interval (every 15 minutes)
terraback drift config --interval 15m

# Configure alerts
terraback drift alert add --email ops@example.com

Set Up Git Integration

# Initialize Git integration
terraback git init

# Configure auto-commit of state changes
terraback git config \
--auto-commit true \
--branch "terraback-states" \
--message "Automated state backup by Terraback"

Working with Multiple Environments

Managing Different Workspaces

# List Terraform workspaces
terraback workspace list

# Backup specific workspace
terraback backup create --workspace staging

# Set default workspace for operations
terraback config set default.workspace production

Environment-Specific Configuration

# Create environment profiles
terraback profile create production \
--storage-bucket prod-terraback \
--retention 90d \
--encryption true

terraback profile create staging \
--storage-bucket staging-terraback \
--retention 7d \
--encryption false

# Switch profiles
terraback profile use production

Essential Commands

Backup Operations

# Create backup with tags
terraback backup create \
--name "release-v2.0" \
--tags "release,production,critical"

# Search backups
terraback backup search --tag "release"

# Delete old backups
terraback backup prune --older-than 30d --dry-run
terraback backup prune --older-than 30d --confirm

Recovery Operations

# Compare current state with backup
terraback diff backup_20240115_143022

# Restore to specific point in time
terraback restore point-in-time "2024-01-15 14:00:00"

# Selective restore (specific resources only)
terraback restore selective backup_20240115_143022 \
--resource aws_instance.web_server \
--resource aws_s3_bucket.assets

Monitoring & Alerts

# View drift summary
terraback drift summary

# Get detailed drift report
terraback drift report --format json > drift-report.json

# Test alert configuration
terraback alert test

# View alert history
terraback alert history --last 24h

Integration Examples

CI/CD Pipeline Integration

GitHub Actions

# .github/workflows/terraback.yml
name: Terraback Backup

on:
push:
branches: [main]
schedule:
- cron: '0 */6 * * *' # Every 6 hours

jobs:
backup:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install Terraback
run: |
curl -sSL https://terraback.io/install.sh | bash

- name: Configure Terraback
env:
TERRABACK_API_KEY: ${{ secrets.TERRABACK_API_KEY }}
run: |
terraback auth login --api-key $TERRABACK_API_KEY

- name: Create Backup
run: |
terraback backup create \
--name "ci-backup-${{ github.sha }}" \
--tags "ci,github,automated"

Jenkins Pipeline

pipeline {
agent any

environment {
TERRABACK_API_KEY = credentials('terraback-api-key')
}

stages {
stage('Backup State') {
steps {
sh '''
terraback backup create \
--name "jenkins-${BUILD_NUMBER}" \
--tags "jenkins,ci,build-${BUILD_NUMBER}"
'''
}
}

stage('Check Drift') {
steps {
sh 'terraback drift check --fail-on-drift'
}
}
}

post {
always {
sh 'terraback backup list --limit 5'
}
}
}

Terraform Integration

Terraform Backend Configuration

# backend.tf
terraform {
backend "s3" {
bucket = "terraform-state"
key = "infrastructure/terraform.tfstate"
region = "us-east-1"
}
}

# terraback.tf
resource "null_resource" "terraback_backup" {
triggers = {
always_run = timestamp()
}

provisioner "local-exec" {
command = "terraback backup create --name 'terraform-apply-${timestamp()}'"
}
}

Monitoring Integration

Prometheus Metrics

# Enable metrics endpoint
terraback metrics enable --port 9090

# Metrics available at http://localhost:9090/metrics
# - terraback_backups_total
# - terraback_backup_size_bytes
# - terraback_drift_detected
# - terraback_restore_operations_total

Datadog Integration

# Configure Datadog integration
terraback integrations add datadog \
--api-key $DATADOG_API_KEY \
--site datadoghq.com

# Send custom metrics
terraback config set metrics.provider datadog

Best Practices

Backup Strategy

  1. Regular Automated Backups: Every hour for production
  2. Manual Checkpoints: Before any significant changes
  3. Retention Policy: 90 days for production, 30 days for staging
  4. Off-site Storage: Use cloud storage for disaster recovery
  5. Encryption: Always enable for sensitive infrastructure

Security Recommendations

# Enable all security features
terraback security enable-all

# Configure encryption
terraback config set encryption.enabled true
terraback config set encryption.algorithm AES-256

# Set up access controls
terraback access add-user alice@example.com --role viewer
terraback access add-user bob@example.com --role operator

# Enable audit logging
terraback audit enable --output /var/log/terraback/

Performance Optimization

# Configure parallel operations
terraback config set performance.parallel_uploads 5

# Enable compression
terraback config set backup.compression gzip
terraback config set backup.compression_level 9

# Optimize for large state files
terraback config set performance.chunk_size 10MB
terraback config set performance.multipart_threshold 100MB

Common Scenarios

Scenario 1: Accidental Deletion Recovery

# Oh no! Someone deleted production resources
# Don't panic, here's how to recover:

# 1. Find the last good backup
terraback backup list --tags production --limit 10

# 2. Preview what will be restored
terraback restore preview backup_20240115_120000

# 3. Restore the state
terraback restore apply backup_20240115_120000 --confirm

# 4. Re-apply Terraform to sync resources
terraform apply

Scenario 2: Rolling Back a Failed Deployment

# Deployment went wrong, need to rollback

# 1. Find the pre-deployment backup
terraback checkpoint list --today

# 2. Restore to checkpoint
terraback restore apply checkpoint_before_deployment

# 3. Verify state is correct
terraform plan # Should show no changes if rolled back correctly

Scenario 3: Investigating Drift

# Detected unexpected changes in production

# 1. Get drift report
terraback drift report --detailed

# 2. Compare with known good state
terraback diff backup_last_known_good

# 3. Generate remediation plan
terraback drift fix --dry-run

# 4. Apply fixes if approved
terraback drift fix --apply

Next Steps

Now that you're familiar with basic operations:

  1. Review CLI Commands Reference for all available commands
  2. Set up Advanced Configuration
  3. Learn Best Practices
  4. Join the Beta Program for early access to new features

Getting Help

Resources

  • Documentation: Full command reference and guides
  • Community Slack: Get help from other users
  • Support Email: support@terraback.io
  • GitHub Issues: Report bugs and request features

Quick Diagnostics

# Run full diagnostics
terraback doctor --verbose

# Generate support bundle
terraback support bundle --output support.zip

# Check service status
terraback service status