> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/argoproj/argo-cd/llms.txt
> Use this file to discover all available pages before exploring further.

# Disaster Recovery

> Backup and restore procedures for Argo CD data and configurations

Argo CD is largely stateless with all data persisted as Kubernetes objects in etcd. This guide covers backup and restore procedures to protect your Argo CD configuration and application definitions.

## Understanding Argo CD Data

Argo CD stores its state in:

* **Kubernetes etcd**: All Application CRDs, AppProjects, and configuration
* **Redis**: Temporary cache only (can be safely rebuilt)
* **Git repositories**: Source of truth for application manifests

<Info>
  Redis is used only as a disposable cache and can be safely rebuilt without service disruption.
</Info>

## Backup Procedures

### Using argocd admin export

The `argocd admin` tool provides built-in export functionality to backup all Argo CD data.

<Steps>
  <Step title="Check Argo CD version">
    Determine your Argo CD version to use the correct Docker image:

    ```bash theme={null}
    argocd version | grep server
    # Export the version
    export VERSION=v3.4.0
    ```
  </Step>

  <Step title="Configure kubeconfig">
    Ensure your `~/.kube/config` points to your Argo CD cluster:

    ```bash theme={null}
    kubectl config current-context
    # Should show your Argo CD cluster
    ```
  </Step>

  <Step title="Export data to backup">
    Create a backup file containing all Argo CD resources:

    ```bash theme={null}
    docker run -v ~/.kube:/home/argocd/.kube --rm \
      quay.io/argoproj/argocd:$VERSION \
      argocd admin export > backup.yaml
    ```

    For non-default namespace:

    ```bash theme={null}
    docker run -v ~/.kube:/home/argocd/.kube --rm \
      quay.io/argoproj/argocd:$VERSION \
      argocd admin export -n <namespace> > backup.yaml
    ```
  </Step>
</Steps>

<Warning>
  If you are running Argo CD in a namespace other than `argocd`, remember to pass the `-n <namespace>` parameter. The export command will not fail if you run it in the wrong namespace, but the backup will be incomplete.
</Warning>

### What Gets Backed Up

The export includes:

* Application definitions
* AppProject configurations
* Repository credentials (encrypted)
* Cluster credentials (encrypted)
* ConfigMaps (argocd-cm, argocd-rbac-cm, etc.)
* Secrets (argocd-secret, repository secrets, cluster secrets)

### Automated Backup Strategy

Implement automated backups using a CronJob:

```yaml theme={null}
apiVersion: batch/v1
kind: CronJob
metadata:
  name: argocd-backup
  namespace: argocd
spec:
  schedule: "0 2 * * *"  # Daily at 2 AM
  jobTemplate:
    spec:
      template:
        spec:
          serviceAccountName: argocd-backup
          containers:
          - name: backup
            image: quay.io/argoproj/argocd:v3.4.0
            command:
            - sh
            - -c
            - |
              argocd admin export > /backup/argocd-backup-$(date +%Y%m%d-%H%M%S).yaml
            volumeMounts:
            - name: backup-storage
              mountPath: /backup
          volumes:
          - name: backup-storage
            persistentVolumeClaim:
              claimName: argocd-backup-pvc
          restartPolicy: OnFailure
```

## Restore Procedures

### Restoring from Backup

<Steps>
  <Step title="Prepare target cluster">
    Install Argo CD on the target cluster if not already present:

    ```bash theme={null}
    kubectl create namespace argocd
    kubectl apply -n argocd -f \
      https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
    ```
  </Step>

  <Step title="Import backup data">
    Restore the backup using the import command:

    ```bash theme={null}
    docker run -i -v ~/.kube:/home/argocd/.kube --rm \
      quay.io/argoproj/argocd:$VERSION \
      argocd admin import - < backup.yaml
    ```

    For non-default namespace:

    ```bash theme={null}
    docker run -i -v ~/.kube:/home/argocd/.kube --rm \
      quay.io/argoproj/argocd:$VERSION \
      argocd admin import -n <namespace> - < backup.yaml
    ```
  </Step>

  <Step title="Verify restoration">
    Check that applications and configurations are restored:

    ```bash theme={null}
    kubectl get applications -n argocd
    kubectl get appprojects -n argocd
    argocd app list
    ```
  </Step>
</Steps>

## Alternative Backup Methods

### Kubernetes etcd Backup

Since Argo CD data lives in Kubernetes, backing up etcd provides a complete snapshot:

```bash theme={null}
ETCDCTL_API=3 etcdctl snapshot save argocd-snapshot.db \
  --endpoints=https://127.0.0.1:2379 \
  --cacert=/etc/kubernetes/pki/etcd/ca.crt \
  --cert=/etc/kubernetes/pki/etcd/server.crt \
  --key=/etc/kubernetes/pki/etcd/server.key
```

### Velero Integration

Use [Velero](https://velero.io/) for cluster-wide backup including Argo CD:

```bash theme={null}
# Install Velero
velero install --provider aws --bucket argocd-backups \
  --secret-file ./credentials-velero

# Create backup schedule
velero schedule create argocd-daily \
  --schedule="@daily" \
  --include-namespaces argocd

# Create on-demand backup
velero backup create argocd-backup-$(date +%Y%m%d) \
  --include-namespaces argocd
```

## Disaster Recovery Scenarios

### Scenario 1: Complete Cluster Loss

<Accordion title="Recovery steps for complete cluster failure">
  1. **Provision new cluster**: Set up a new Kubernetes cluster
  2. **Install Argo CD**: Deploy Argo CD fresh installation
  3. **Restore backup**: Import the latest backup file
  4. **Verify applications**: Check that all applications are present
  5. **Trigger sync**: Applications will automatically reconcile with Git

  ```bash theme={null}
  # Quick recovery script
  kubectl create namespace argocd
  kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
  sleep 60
  docker run -i -v ~/.kube:/home/argocd/.kube --rm \
    quay.io/argoproj/argocd:$VERSION \
    argocd admin import - < backup.yaml
  ```
</Accordion>

### Scenario 2: Corrupted Application State

<Accordion title="Recovery steps for corrupted application data">
  1. **Identify affected applications**: Review application health status
  2. **Delete corrupted application**: Remove the Application CR
  3. **Restore from backup**: Import backup or recreate from Git
  4. **Resync application**: Trigger full sync

  ```bash theme={null}
  # Delete and restore specific application
  kubectl delete application myapp -n argocd
  kubectl apply -f myapp-backup.yaml
  argocd app sync myapp --force
  ```
</Accordion>

### Scenario 3: Lost Repository Credentials

<Accordion title="Recovery steps for lost credentials">
  Repository credentials are stored in Kubernetes secrets:

  ```bash theme={null}
  # Export repository secrets from backup
  kubectl apply -f - <<EOF
  apiVersion: v1
  kind: Secret
  metadata:
    name: repo-credentials
    namespace: argocd
    labels:
      argocd.argoproj.io/secret-type: repository
  type: Opaque
  stringData:
    url: https://github.com/org/repo
    username: git
    password: <token>
  EOF
  ```
</Accordion>

## Best Practices

<CardGroup cols={2}>
  <Card title="Regular Backups" icon="clock">
    Schedule automated backups daily or before major changes. Store backups in multiple locations.
  </Card>

  <Card title="Test Restores" icon="flask">
    Regularly test restore procedures in a non-production environment to verify backup integrity.
  </Card>

  <Card title="Version Compatibility" icon="code-branch">
    Use the same Argo CD version for backup and restore operations to avoid compatibility issues.
  </Card>

  <Card title="Secure Storage" icon="lock">
    Encrypt backup files and store them in secure, access-controlled locations with retention policies.
  </Card>
</CardGroup>

## Backup Retention Policy

Implement a retention strategy:

* **Daily backups**: Retain for 7 days
* **Weekly backups**: Retain for 4 weeks
* **Monthly backups**: Retain for 12 months
* **Pre-upgrade backups**: Retain indefinitely

```bash theme={null}
# Cleanup old backups (older than 7 days)
find /backup/argocd-* -mtime +7 -delete
```

## Recovery Time Objective (RTO)

Typical recovery times:

| Scenario             | Expected RTO  | Notes                          |
| -------------------- | ------------- | ------------------------------ |
| Application restore  | 5-10 minutes  | Single application from backup |
| Full Argo CD restore | 30-60 minutes | Complete installation + import |
| Cluster rebuild      | 2-4 hours     | New cluster + Argo CD + apps   |

## Related Resources

* [High Availability Setup](/operations/high-availability)
* [Upgrading Argo CD](/operations/upgrading)
* [Monitoring and Alerts](/operations/monitoring)
