This page looks best with JavaScript enabled

FoundationDB Data Backup and Restore

 ·  ☕ 2 min read

1. Set Environment Variables

  • Set the foundationdb cluster name and version
1
2
3
4
5
export CLUSTER_NAME=
export NAMESPACE=
export DEPLOY_NAME=${CLUSTER_NAME}-deployment
export SECRET_NAME=fdb-backup-secret
export VERSION=7.1.26
  • Set the S3 backup bucket and credentials
1
2
3
4
5
export BUCKET=
export HOST=s3.us-west-2.amazonaws.com
export AK=x
export SK=x
export S3_BACKUP_URI="blobstore://${AK}:${SK}@${HOST}/fdb-backup?bucket=${BUCKET}&sc=0"

2. Create the Credentials

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Secret
metadata:
  name: ${SECRET_NAME}
  namespace: ${NAMESPACE}
type: Opaque
stringData:
  credentials: |
    {
      "accounts": {
        "${BUCKET}@${HOST}": {
          "access_key": "${AK}",
          "secret": "${SK}",
          "endpoint": "${HOST}"
        }
      }
    }
EOF

3. Create the Backup Workload

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
kubectl apply -f - <<EOF
apiVersion: apps.foundationdb.org/v1beta2
kind: FoundationDBBackup
metadata:
  name: ${CLUSTER_NAME}
  namespace: ${NAMESPACE}
spec:
  version: ${VERSION}
  clusterName: ${CLUSTER_NAME}
  snapshotPeriodSeconds: 3600
  blobStoreConfiguration:
    accountName: ${BUCKET}@${HOST}
    urlParameters:
    - "secure_connection=0"
  podTemplateSpec:
    spec:
      volumes:
        - name: backup-credentials
          secret:
            secretName: ${SECRET_NAME}
      containers:
        - name: foundationdb
          env:
            - name: FDB_BLOB_CREDENTIALS
              value: /var/backup-credentials/credentials
          volumeMounts:
            - name: backup-credentials
              mountPath: /var/backup-credentials
  sidecarContainer:
      imageConfigs:
        - baseImage: foundationdb/foundationdb-kubernetes-sidecar
          tag: ${VERSION}-1
  mainContainer:
    imageConfigs:
      - baseImage: foundationdb/foundationdb
        tag: ${VERSION}
EOF
  • Delete the backup workload
1
kubectl delete foundationdbbackups.apps.foundationdb.org ${CLUSTER_NAME}

4. Back Up FoundationDB Data

4.1 Enter the Backup Container

1
kubectl -n ${NAMESPACE} exec -it deployment/${CLUSTER_NAME}-backup-agents -- bash

4.2 Back Up to an S3 Bucket

1
2
3
4
5
fdbbackup start \
  --destcontainer "${S3_BACKUP_URI}" \
  --cluster-file "$FDB_CLUSTER_FILE" \
  --knob_http_verbose_level=3 \
  --log -t ${NAMESPACE}-${CLUSTER_NAME}-1 -w
1
fdbbackup status --cluster-file "$FDB_CLUSTER_FILE" -t ${NAMESPACE}-${CLUSTER_NAME}-1

4.3 Back Up to a Local Disk

  • Back up
1
2
3
4
fdbbackup start \
  --destcontainer "file:///data/fdb-backup" \
  --cluster-file "$FDB_CLUSTER_FILE" \
  -t local-test
  • Check the backup status
1
fdbbackup status --cluster-file "$FDB_CLUSTER_FILE" -t s3-test-3
BackupUID: e698f34883432d9bd4a4c436bc0c21bb
BackupURL: file:///data/fdb-backup/backup-2025-06-09-06-52-04.909367
  • Package
1
tar -czvf backup-2025-06-09.tar.gz -C /data/fdb-backup

5. Restore Data

5.1 Clear the Data

If you are backing up and restoring between different instances, you first need to clear the data on the instance to be restored.

  • View the data
1
fdbcli --exec "getrange '' \xFF"
  • Clear the data
1
fdbcli --exec "writemode on; clearrange '' \xFF"

5.2 Restore the Data

1
2
3
4
5
fdbrestore start \
  -r "${S3_BACKUP_URI}" \
  --dest-cluster-file "$FDB_CLUSTER_FILE" \
  --knob_http_verbose_level=3 \
  --log -t default-fdb-deploy-test-1 -w

The -r parameter specifies the storage location of the backup, which can be an S3 bucket or a local disk.


微信公众号
WRITTEN BY
微信公众号