备份、聚合和恢复(在线)

Neo4j 使用 Admin Service 执行备份,该服务仅在 Kubernetes 集群内部可用,且应保护对其的访问。更多信息,请参阅 访问 Neo4j

备份存储选项

Neo4j 的 Helm chart 支持全量和差异备份,并可配置为使用云提供商存储或本地存储。

云存储

Neo4j Helm chart 使用 Neo4j 原生云存储集成,通过直接上传来创建不可变的备份对象。这使您可以将 Neo4j 数据库直接备份到云存储,而无需持久卷。通过在 backup-values.yaml 文件中将 cloudProvider 参数设置为 awsgcpazure,可以将 chart 配置为使用 AWS S3、Google Cloud Storage 和 Azure Blob Storage 等云提供商。

支持以下功能

  • 直接云存储上传 - 无需中间本地存储。

  • 差异备份链,使用 preferDiffAsParent: true

  • 云存储中的不可变备份对象

  • 支持 S3 兼容端点.

  • 增强的 S3 配置,包括自定义 CA 证书和端点设置。

本地存储

本地存储在 /backups 挂载点创建本地备份。对于大型数据库,必须配置此挂载点以使用 tempVolume 的持久化存储。cloudProvider 必须为空。

准备将数据库备份到云提供商(AWS、GCP 和 Azure)存储桶

您可以使用 neo4j/neo4j-admin Helm chart 将 Neo4j 数据库备份到任何云提供商(AWS、GCP 和 Azure)的存储桶中。neo4j/neo4j-admin Helm chart 还支持备份多个数据库、GCP/AWS/Azure 的工作负载身份(Workload Identity)集成,以及用于非 TLS/SSL 端点的 MinIO(一种 AWS S3 兼容的对象存储 API)。

先决条件

在备份数据库并将其上传到存储桶之前,请验证您是否具备以下条件

使用云提供商时,差异备份不需要包含先前备份的持久卷。相反,chart 会首先在云存储中创建全量备份,后续备份将作为引用此全量备份的差异备份。

创建 Kubernetes Secret

您可以使用以下选项之一创建包含可访问云提供商存储桶的凭据的 Kubernetes Secret

使用您的 GCP 服务账号 JSON 密钥文件创建名为 gcpcreds 的 Secret。JSON 密钥文件包含有权访问存储桶的服务账号的所有详细信息。

kubectl create secret generic gcpcreds --from-file=credentials=/path/to/gcpcreds.json
  1. 按以下格式创建凭据文件

    [ default ]
    region = us-east-1
    aws_access_key_id = <your-aws_access_key_id>
    aws_secret_access_key = <your-aws_secret_access_key>
  2. 通过凭据文件创建名为 awscreds 的 Secret

    kubectl create secret generic awscreds --from-file=credentials=/path/to/your/credentials
  1. 按以下格式创建凭据文件(2025.06 之前)

    AZURE_STORAGE_ACCOUNT_NAME=<your-azure-storage-account-name>
    AZURE_STORAGE_ACCOUNT_KEY=<your-azure-storage-account-key>

    从 2025.06 开始,按如下方式更新您的凭据 Secret

    # Azure credentials file
    AZURE_STORAGE_ACCOUNT=<your_account>
    AZURE_STORAGE_KEY=<your_key>
    AZURE_CLIENT_ID=<your_service_principal_id>
    AZURE_CLIENT_SECRET=<your_service_principal_secret>
    AZURE_TENANT_ID=<your_tenant_id>
  2. 通过凭据文件创建名为 azurecred 的 Secret

    kubectl create secret generic azurecred --from-file=credentials=/path/to/your/credentials

配置备份参数

您可以通过使用 secretNamesecretKeyName 参数,或者通过将 Kubernetes 服务账号映射到工作负载身份集成,在 backup-values.yaml 文件中配置备份参数。

以下示例显示了执行备份到云提供商存储桶所需的最少配置。有关可用备份参数的更多信息,请参阅 备份参数

使用 secretNamesecretKeyName 参数配置 backup-values.yaml 文件

neo4j:
  image: "neo4j/helm-charts-backup"
  imageTag: "2026.03.1"
  jobSchedule: "* * * * *"
  successfulJobsHistoryLimit: 3
  failedJobsHistoryLimit: 1
  backoffLimit: 3

backup:
  bucketName: "my-bucket"
  databaseAdminServiceName:  "standalone-admin" #This is the Neo4j Admin Service name.
  database: "neo4j,system"
  cloudProvider: "gcp"
  secretName: "gcpcreds"
  secretKeyName: "credentials"
  # Enable cloud-native differential backups
  preferDiffAsParent: true
  type: "AUTO"  # First backup will be FULL, subsequent ones DIFF
  fallbackToFull: true

consistencyCheck:
  enabled: true
neo4j:
  image: "neo4j/helm-charts-backup"
  imageTag: "2026.03.1"
  jobSchedule: "* * * * *"
  successfulJobsHistoryLimit: 3
  failedJobsHistoryLimit: 1
  backoffLimit: 3

backup:
  bucketName: "my-bucket"
  databaseAdminServiceName:  "standalone-admin"
  database: "neo4j,system"
  cloudProvider: "aws"
  secretName: "awscreds"
  secretKeyName: "credentials"
  # Enable cloud-native differential backups
  preferDiffAsParent: true
  type: "AUTO"  # First backup will be FULL, subsequent ones DIFF
  fallbackToFull: true

consistencyCheck:
  enabled: true
neo4j:
  image: "neo4j/helm-charts-backup"
  imageTag: "2026.03.1"
  jobSchedule: "* * * * *"
  successfulJobsHistoryLimit: 3
  failedJobsHistoryLimit: 1
  backoffLimit: 3

backup:
  bucketName: "my-bucket"
  databaseAdminServiceName:  "standalone-admin"
  database: "neo4j,system"
  cloudProvider: "azure"
  secretName: "azurecreds"
  secretKeyName: "credentials"
  # Enable cloud-native differential backups
  preferDiffAsParent: true
  type: "AUTO"  # First backup will be FULL, subsequent ones DIFF
  fallbackToFull: true

consistencyCheck:
  enabled: true

使用服务账号工作负载身份集成配置 backup-values.yaml 文件

在某些情况下,将带有工作负载身份集成的 Kubernetes 服务账号分配给 Neo4j 备份 Pod 会很有用。当您想要提高安全性并对 Pod 进行更精确的访问控制时,这一点尤为重要。这样做可以确保基于 Pod 在云生态系统中的身份授予对资源的安全访问权限。有关设置带有工作负载身份的服务账号的更多信息,请参阅 Google Kubernetes Engine (GKE) → 使用工作负载身份Amazon EKS → 配置 Kubernetes 服务账号以承担 IAM 角色,以及 Microsoft Azure → 在 Azure Kubernetes Service (AKS) 中使用 Microsoft Entra 工作负载 ID

要配置 Neo4j 备份 Pod 以使用带有工作负载身份的 Kubernetes 服务账号,请将 serviceAccountName 设置为要使用的服务账号名称。对于 Azure 部署,您还需要将 azureStorageAccountName 参数设置为将要上传备份文件的 Azure 存储账号名称。例如

neo4j:
  image: "neo4j/helm-charts-backup"
  imageTag: "2026.03.1"
  jobSchedule: "* * * * *"
  successfulJobsHistoryLimit: 3
  failedJobsHistoryLimit: 1
  backoffLimit: 3

backup:
  bucketName: "my-bucket"
  databaseAdminServiceName:  "standalone-admin" #This is the Neo4j Admin Service name.
  database: "neo4j,system"
  cloudProvider: "gcp"
  secretName: ""
  secretKeyName: ""
  # Enable cloud-native differential backups
  preferDiffAsParent: true
  type: "AUTO"  # First backup will be FULL, subsequent ones DIFF
  fallbackToFull: true

consistencyCheck:
  enabled: true

serviceAccountName: "demo-service-account"
neo4j:
  image: "neo4j/helm-charts-backup"
  imageTag: "2026.03.1"
  jobSchedule: "* * * * *"
  successfulJobsHistoryLimit: 3
  failedJobsHistoryLimit: 1
  backoffLimit: 3

backup:
  bucketName: "my-bucket"
  databaseAdminServiceName:  "standalone-admin"
  database: "neo4j,system"
  cloudProvider: "aws"
  secretName: ""
  secretKeyName: ""
  # Enable cloud-native differential backups
  preferDiffAsParent: true
  type: "AUTO"  # First backup will be FULL, subsequent ones DIFF
  fallbackToFull: true

consistencyCheck:
  enabled: true

serviceAccountName: "demo-service-account"
neo4j:
  image: "neo4j/helm-charts-backup"
  imageTag: "2026.03.1"
  jobSchedule: "* * * * *"
  successfulJobsHistoryLimit: 3
  failedJobsHistoryLimit: 1
  backoffLimit: 3

backup:
  bucketName: "my-bucket"
  databaseAdminServiceName:  "standalone-admin"
  database: "neo4j,system"
  cloudProvider: "azure"
  azureStorageAccountName: "storageAccountName"
  # Enable cloud-native differential backups
  preferDiffAsParent: true
  type: "AUTO"  # First backup will be FULL, subsequent ones DIFF
  fallbackToFull: true

consistencyCheck:
  enabled: true

serviceAccountName: "demo-service-account"

默认创建的 /backups 挂载点是 emptyDir 类型的卷。这意味着存储在此卷中的数据不是持久化的,Pod 删除时数据会丢失。要为备份使用持久卷,请将以下部分添加到 backup-values.yaml 文件中

tempVolume:
  persistentVolumeClaim:
    claimName: backup-pvc

仅在使用本地存储时,您才需要在安装 neo4j-admin Helm chart 之前创建持久卷和持久卷声明。在使用云提供商时,差异备份不需要持久卷。更多信息,请参阅 卷挂载和持久卷

配置 S3 兼容存储端点

备份系统支持任何 S3 兼容的存储服务。您可以在 backup-values.yaml 文件中使用以下参数配置 TLS 和非 TLS 端点

backup:
  # Specify your S3-compatible endpoint (e.g., https://s3.amazonaws.com or your custom endpoint)
  s3Endpoint: "https://s3.custom-provider.com"

  # Enable TLS for secure connections (default: false)
  s3EndpointTLS: true

  # Optional: Provide a base64-encoded CA certificate for custom certificate authorities
  s3CACert: "base64_encoded_ca_cert_data"

  # Optional: Skip TLS verification (not recommended for production)
  s3SkipVerify: false

  # Optional: Force path-style addressing for S3 requests
  s3ForcePathStyle: true

  # Optional: Specify S3 region
  s3Region: "us-east-1"

  # Alternative: Use Kubernetes secret for CA certificate
  s3CASecretName: "s3-ca-cert"
  s3CASecretKey: "ca.crt"

以下是如何为不同的 S3 兼容存储提供商配置备份系统的示例

AWS S3 标准端点
neo4j:
  image: "neo4j/helm-charts-backup"
  imageTag: "2026.03.1"
  jobSchedule: "* * * * *"
  successfulJobsHistoryLimit: 3
  failedJobsHistoryLimit: 1
  backoffLimit: 3

backup:
  bucketName: "my-bucket"
  databaseAdminServiceName: "standalone-admin"
  s3Endpoint: "https://s3.amazonaws.com"
  s3EndpointTLS: true
  database: "neo4j,system"
  cloudProvider: "aws"
  secretName: "awscreds"
  secretKeyName: "credentials"

consistencyCheck:
  enabled: true
带有自签名证书的自定义 S3 兼容提供商
backup:
  bucketName: "my-bucket"
  s3Endpoint: "https://custom-s3.example.com"
  s3EndpointTLS: true
  s3CACert: "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0t..."  # Base64-encoded CA cert
  cloudProvider: "aws"
  secretName: "awscreds"
  secretKeyName: "credentials"
旧版 MinIO 支持
backup:
  bucketName: "my-bucket"
  databaseAdminServiceName: "standalone-admin"
  minioEndpoint: "http://minio.example.com:9000"  # Deprecated: Use s3Endpoint instead
  database: "neo4j,system"
  cloudProvider: "aws"
  secretName: "awscreds"
  secretKeyName: "credentials"
  • 使用 HTTPS 端点时,s3EndpointTLS 参数必须设置为 true

  • 使用自定义 CA 证书时,请以 base64 编码格式提供在 s3CACert 参数中。

  • s3SkipVerify 参数仅应在开发环境中使用。

  • 通过 minioEndpoint 参数提供的旧版 MinIO 支持已弃用 - 请改用 s3Endpoint

S3 CA 证书设置

对于带有自定义 CA 证书的 S3 端点,请使用 Kubernetes Secret 来管理 CA 证书

  1. 创建 CA 证书 Secret

    kubectl create secret generic s3-ca-cert --from-file=ca.crt=/path/to/your/ca.crt
  2. 配置备份作业

    backup:
      cloudProvider: "aws"
      s3Endpoint: "https://your-s3-endpoint.com"
      s3CASecretName: "s3-ca-cert"
      s3CASecretKey: "ca.crt"
      s3EndpointTLS: true  # Automatically set when s3CASecretName is provided

准备将数据库备份到本地存储

您可以使用 neo4j/neo4j-admin Helm chart 将 Neo4j 数据库备份到本地存储。配置 backup-values.yaml 文件时,请保持 “cloudProvider” 字段为空,并在 tempVolume 部分提供持久卷,以确保如果 Pod 被删除,备份文件是持久化的。

仅在使用本地存储时,您才需要在安装 neo4j-admin Helm chart 之前创建持久卷和持久卷声明。在使用云提供商时,差异备份不需要持久卷。更多信息,请参阅 卷挂载和持久卷

例如:

neo4j:
  image: "neo4j/helm-charts-backup"
  imageTag: "2026.03.1"
  jobSchedule: "* * * * *"
  successfulJobsHistoryLimit: 3
  failedJobsHistoryLimit: 1
  backoffLimit: 3

backup:
  bucketName: "my-bucket"
  databaseAdminServiceName:  "standalone-admin"
  database: "neo4j,system"
  cloudProvider: ""

consistencyCheck:
  enabled: true

tempVolume:
  persistentVolumeClaim:
    claimName: backup-pvc

备份参数

要查看 Helm chart 上可配置的选项,请使用 helm show values 命令和 neo4j/neo4j-admin Helm chart。
neo4j/neo4j-admin Helm chart 还支持使用 nodeSelector 标签以及亲和性/反亲和性规则或容忍度(Tolerations)将 Neo4j Pod 分配到特定节点。更多信息,请参阅 将备份 Pod 分配到特定节点 以及 Kubernetes 官方文档关于 亲和性与反亲和性 规则和 污点与容忍度 的介绍。

例如:

helm show values neo4j/neo4j-admin
## @param nameOverride String to partially override common.names.fullname
nameOverride: ""
## @param fullnameOverride String to fully override common.names.fullname
fullnameOverride: ""
# disableLookups will disable all the lookups done in the helm charts
# This should be set to true when using ArgoCD since ArgoCD uses helm template and the helm lookups will fail
# You can enable this when executing helm commands with --dry-run command
disableLookups: false

neo4j:
  image: "neo4j/helm-charts-backup"
  imageTag: "2026.03.1"
  podLabels: {}
#    app: "demo"
#    acac: "dcdddc"
  podAnnotations: {}
#    ssdvvs: "svvvsvs"
#    vfsvswef: "vcfvgb"
  # define the backup job schedule . default is * * * * *
  jobSchedule: ""
  # default is 3
  successfulJobsHistoryLimit:
  # default is 1
  failedJobsHistoryLimit:
  # default is 3
  backoffLimit:
  #add labels if required
  labels: {}

backup:
  # Ensure the bucket is already existing in the respective cloud provider
  # In case of azure the bucket is the container name in the storage account
  # bucket: azure-storage-container
  bucketName: ""
  # Specify multiple backup endpoints as comma-separated string
  # e.g. "10.3.3.2:6362,10.3.3.3:6362,10.3.3.4:6362"
  databaseBackupEndpoints: ""
  #ex: standalone-admin.default.svc.cluster.local:6362
  # admin service name -  standalone-admin
  # namespace - default
  # cluster domain - cluster.local
  # port - 6362

  #ex: 10.3.3.2:6362
  # admin service ip - 10.3.3.2
  # port - 6362

  databaseAdminServiceName: ""
  databaseAdminServiceIP: ""
  #default name is 'default'
  databaseNamespace: ""
  #default port is 6362
  databaseBackupPort: ""
  #default value is cluster.local
  databaseClusterDomain: ""
  # specify S3-compatible endpoint (e.g., http://s3.amazonaws.com or your custom S3 endpoint)
  # This can be any S3-compatible endpoint including AWS S3, MinIO, or other S3-compatible storage services
  # For TLS endpoints (https), set s3EndpointTLS to true
  s3Endpoint: ""
  # Enable TLS for S3 endpoint (default: false)
  s3EndpointTLS: false
  # Optional: Base64-encoded CA certificate for S3 endpoint TLS verification
  # Only needed for self-signed certificates or private CA
  s3CACert: ""
  # Optional: Skip TLS verification (not recommended for production)
  s3SkipVerify: false
  # Optional: Force path-style addressing for S3 requests
  s3ForcePathStyle: false
  # Optional: Specify S3 region
  s3Region: ""
  # Alternative: Use Kubernetes secret for CA certificate
  s3CASecretName: ""
  s3CASecretKey: ""
  #name of the database to backup ex: neo4j or neo4j,system (You can provide command separated database names)
  # In case of comma separated databases failure of any single database will lead to failure of complete operation
  database: ""
  # cloudProvider can be either gcp, aws, or azure
  # if cloudProvider is empty then the backup will be done to the /backups mount.
  # the /backups mount can point to a persistentVolume based on the definition set in tempVolume
  cloudProvider: ""



  # name of the kubernetes secret containing the respective cloud provider credentials
  # Ensure you have read,write access to the mentioned bucket
  # For AWS :
  # add the below in a file and create a secret via
  # 'kubectl create secret generic awscred --from-file=credentials=/demo/awscredentials'

  #  [ default ]
  #  region = us-east-1
  #  aws_access_key_id = XXXXX
  #  aws_secret_access_key = XXXX

  # For AZURE :
  # add the storage account name and key in below format in a file create a secret via
  # 'kubectl create secret generic azurecred --from-file=credentials=/demo/azurecredentials'

  #  AZURE_STORAGE_ACCOUNT_NAME=XXXX
  #  AZURE_STORAGE_ACCOUNT_KEY=XXXX

  # For GCP :
  # create the secret via the gcp service account json key file.
  # ex: 'kubectl create secret generic gcpcred --from-file=credentials=/demo/gcpcreds.json'
  secretName: ""
  # provide the keyname used in the above secret
  secretKeyName: ""
  # provide the azure storage account name
  # this to be provided when you are using workload identity integration for azure
  azureStorageAccountName: ""
  #setting this to true will not delete the backup files generated at the /backup mount
  keepBackupFiles: true

  #Below are all neo4j-admin database backup flags / options
  #To know more about the flags read here : /docs/operations-manual/current/backup-restore/online-backup/
  pageCache: ""
  includeMetadata: "all"
  type: "AUTO"
  keepFailed: false
  parallelRecovery: false
  verbose: true
  heapSize: ""
  # Enable differential backups using the latest differential backup as parent
  # This eliminates the need for persistent volumes when using cloud providers
  preferDiffAsParent: false
  # Fallback to FULL backup if DIFF backup fails
  fallbackToFull: true

  # /docs/operations-manual/current/backup-restore/aggregate/
  # Performs aggregate backup. If enabled, NORMAL BACKUP WILL NOT BE DONE only aggregate backup
  # fromPath supports only s3 or local mount. For s3 , please set cloudProvider to aws and use either serviceAccount or creds
  aggregate:
    enabled: false
    verbose: true
    keepOldBackup: false
    parallelRecovery: false
    # Only AWS S3 or local mount paths are supported
    # For S3 provide the complete path , Ex: s3://bucket1/bucket2
    fromPath: ""
    # database name to aggregate. Can contain * and ? for globbing.
    database: ""
    # Optional temporary directory for aggregation process
    # If not specified, will use the backup directory
    tempDir: ""

#Below are all neo4j-admin database check flags / options
#To know more about the flags read here : /docs/operations-manual/current/backup-restore/consistency-checker/
consistencyCheck:
  enable: false
  checkIndexes: true
  checkGraph: true
  checkCounts: true
  checkPropertyOwners: true
  #The database name for which consistency check needs to be done.
  #Defaults to the backup.database values if left empty
  #The database name here should match with one of the database names present in backup.database. If not , the consistency check will be ignored
  database: ""
  maxOffHeapMemory: ""
  threads: ""
  verbose: true

# Set to name of an existing Service Account to use if desired
# Follow the following links for setting up a service account with workload identity
# Azure - https://learn.microsoft.com/en-us/azure/aks/workload-identity-overview?tabs=go
# GCP - https://cloud.google.com/kubernetes-engine/docs/how-to/workload-identity
# AWS - https://docs.aws.amazon.com/eks/latest/userguide/associate-service-account-role.html
serviceAccountName: ""

# Volume to use as temporary storage for files before they are uploaded to cloud. For large databases local storage may not have sufficient space.
# In that case set an ephemeral or persistent volume with sufficient space here
# The chart defaults to an emptyDir, use this to overwrite default behavior
#tempVolume:
#  persistentVolumeClaim:
#    claimName: backup-pvc

# securityContext defines privilege and access control settings for a Pod. Making sure that we don't run Neo4j as root user.
securityContext:
  runAsNonRoot: true
  runAsUser: 7474
  runAsGroup: 7474
  fsGroup: 7474
  fsGroupChangePolicy: "Always"

containerSecurityContext:
  runAsNonRoot: true
  runAsUser: 7474
  runAsGroup: 7474
  readOnlyRootFilesystem: false
  allowPrivilegeEscalation: false
  capabilities:
    drop: ["ALL"]
# default ephemeral storage of backup container
resources:
  requests:
    ephemeralStorage: "4Gi"
    cpu: ""
    memory: ""
  limits:
    ephemeralStorage: "5Gi"
    cpu: ""
    memory: ""

# nodeSelector labels
# please ensure the respective labels are present on one of nodes or else helm charts will throw an error
nodeSelector: {}
#  label1: "true"
#  label2: "value1"

# set backup pod affinity
affinity: {}
#  podAffinity:
#    requiredDuringSchedulingIgnoredDuringExecution:
#      - labelSelector:
#          matchExpressions:
#            - key: security
#              operator: In
#              values:
#                - S1
#        topologyKey: topology.kubernetes.io/zone
#  podAntiAffinity:
#    preferredDuringSchedulingIgnoredDuringExecution:
#      - weight: 100
#        podAffinityTerm:
#          labelSelector:
#            matchExpressions:
#              - key: security
#                operator: In
#                values:
#                  - S2
#          topologyKey: topology.kubernetes.io/zone

#Add tolerations to the Neo4j pod
tolerations: []
#  - key: "key1"
#    operator: "Equal"
#    value: "value1"
#    effect: "NoSchedule"
#  - key: "key2"
#    operator: "Equal"
#    value: "value2"
#    effect: "NoSchedule"

备份您的数据库

要备份您的数据库,请使用配置好的 backup-values.yaml 文件安装 neo4j-admin Helm chart。

  1. 使用 backup-values.yaml 文件安装 neo4j-admin Helm chart

    helm install backup-name neo4j/neo4j-admin -f /path/to/your/backup-values.yaml

    neo4j/neo4j-admin Helm chart 会安装一个 CronJob,根据作业计划启动 Pod。此 Pod 执行一个或多个数据库的备份、备份文件的一致性检查,并将其上传到云提供商存储桶。

  2. 使用 kubectl logs pod/<neo4j-backup-pod-name> 监控备份 Pod 的日志,以检查备份进度。

  3. 检查备份文件和一致性检查报告是否已上传到云提供商存储桶或本地存储。

聚合数据库备份链

聚合备份命令将备份链转换为单个备份文件。当您想要将备份链恢复到不同的集群,或想要归档备份链时,这非常有用。有关聚合备份链操作的好处、语法和可用选项的更多信息,请参阅 聚合数据库备份链

从 5.26 LTS 开始,neo4j-admin Helm chart 支持一个可选的临时目录,供聚合过程使用,而不是使用备份工作目录。当备份链的大小大于 Pod 的临时存储空间时,这特别有用。为了避免备份聚合作业因磁盘空间不足而失败,您可以将 tempDir 参数设置为具有足够空间容纳备份文件的持久卷声明。

neo4j-admin Helm chart 支持聚合存储在 AWS S3 存储桶或本地挂载点中的备份链。如果启用,将不会执行常规备份,仅执行聚合备份。

  1. 要聚合存储在 AWS S3 存储桶或本地挂载点中的备份链,您需要在 backup-values.yaml 文件中提供以下信息

    如果您的备份链存储在 AWS S3 上,您需要将 cloudProvider 设置为 aws,并使用 credsserviceAccount 连接到您的 AWS S3 存储桶。例如

    使用 awscreds Secret 连接到您的 AWS S3 存储桶
    neo4j:
      image: "neo4j/helm-charts-backup"
      imageTag: "2026.03.1"
      jobSchedule: "* * * * *"
      successfulJobsHistoryLimit: 3
      failedJobsHistoryLimit: 1
      backoffLimit: 3
    
    backup:
    
      cloudProvider: "aws"
      secretName: "awscreds"
      secretKeyName: "credentials"
    
      aggregate:
        enabled: true
        verbose: false
        keepOldBackup: false
        parallelRecovery: false
        fromPath: "s3://bucket1/bucket2"
        # Database name to aggregate. Can contain * and ? for globbing.
        database: "neo4j"
        # Optional temporary directory for aggregation process
        # If not specified, will use the backup directory
        tempDir: "/custom/temp/dir"
    
    resources:
      requests:
        ephemeralStorage: "4Gi"
      limits:
        ephemeralStorage: "5Gi"
    使用 serviceAccount 连接到您的 AWS S3 存储桶
    neo4j:
      image: "neo4j/helm-charts-backup"
      imageTag: "2026.03.1"
      jobSchedule: "* * * * *"
      successfulJobsHistoryLimit: 3
      failedJobsHistoryLimit: 1
      backoffLimit: 3
    
    backup:
    
        cloudProvider: "aws"
    
        aggregate:
          enabled: true
          verbose: false
          keepOldBackup: false
          parallelRecovery: false
          fromPath: "s3://bucket1/bucket2"
          # Database name to aggregate. Can contain * and ? for globbing.
          database: "neo4j"
          # Optional temporary directory for aggregation process
          # If not specified, will use the backup directory
          tempDir: "/custom/temp/dir"
    
    #The service account must already exist in your cloud provider account and have the necessary permissions to manage your S3 bucket, as well as to download and upload files. See the example policy below.
    #{
    #   "Version": "2012-10-17",
    #    "Id": "Neo4jBackupAggregatePolicy",
    #    "Statement": [
    #        {
    #            "Sid": "Neo4jBackupAggregateStatement",
    #            "Effect": "Allow",
    #            "Action": [
    #                "s3:ListBucket",
    #                "s3:GetObject",
    #                "s3:PutObject",
    #                "s3:DeleteObject"
    #            ],
    #            "Resource": [
    #                "arn:aws:s3:::mybucket/*",
    #                "arn:aws:s3:::mybucket"
    #            ]
    #        }
    #    ]
    #}
    serviceAccountName: "my-service-account"
    
    resources:
      requests:
        ephemeralStorage: "4Gi"
      limits:
        ephemeralStorage: "5Gi"
    neo4j:
      image: "neo4j/helm-charts-backup"
      imageTag: "2026.03.1"
      successfulJobsHistoryLimit: 1
      failedJobsHistoryLimit: 1
      backoffLimit: 1
    
    backup:
    
      aggregate:
        enabled: true
        verbose: false
        keepOldBackup: false
        parallelRecovery: false
        fromPath: "/backups"
        # Database name to aggregate. Can contain * and ? for globbing.
        database: "neo4j"
        # Optional temporary directory for aggregation process
        # If not specified, will use the backup directory
        tempDir: "/custom/temp/dir"
    
    tempVolume:
      persistentVolumeClaim:
        claimName: aggregate-pv-pvc
    
    resources:
      requests:
        ephemeralStorage: "4Gi"
      limits:
        ephemeralStorage: "5Gi"
  2. 使用配置好的 backup-values.yaml 文件安装 neo4j-admin Helm chart

    helm install backup-name neo4j/neo4j-admin -f /path/to/your/backup-values.yaml
  3. 使用 kubectl logs pod/<neo4j-aggregate-backup-pod-name> 监控 Pod 日志,以检查聚合备份操作的进度。

  4. 验证聚合后的备份文件已替换云提供商存储桶或本地存储中的备份链。

恢复单个数据库

要恢复单个离线数据库或数据库备份,除非您想将备份作为 DBMS 中的额外数据库恢复,否则首先需要删除要替换的数据库。然后,使用 neo4j-admin 的 restore 命令恢复数据库备份。最后,使用 Cypher 命令 CREATE DATABASE namesystem 数据库中创建恢复后的数据库。

删除要替换的数据库

在恢复数据库备份之前,您必须使用 system 数据库上的 Cypher 命令 DROP DATABASE name 删除要替换的数据库。如果您想将备份作为 DBMS 中的额外数据库恢复,则可以跳至下一节。

对于 Neo4j 集群部署,您只需在其中一个集群服务器上运行 DROP DATABASE name 命令。该命令会自动从那里路由到其他集群成员。

  1. 连接到 Neo4j DBMS

    kubectl exec -it <release-name>-0 -- bash
  2. 使用 cypher-shell 连接到 system 数据库

    cypher-shell -u neo4j -p <password> -d system
  3. 删除您要用备份替换的数据库

    DROP DATABASE neo4j;
  4. 通过键入 :exit; 退出 Cypher Shell 命令行控制台。

恢复数据库备份

您使用 neo4j-admin database restore 命令恢复数据库备份,然后使用 Cypher 命令 CREATE DATABASE namesystem 数据库中创建恢复后的数据库。有关命令语法、选项和用法的更多信息,请参阅 恢复数据库备份

对于 Neo4j 集群部署,请在每个集群服务器上恢复数据库备份。

  1. 运行 neo4j-admin database restore 命令恢复数据库备份

    neo4j-admin database restore neo4j --from-path=/backups/neo4j --expand-commands
  2. 使用 cypher-shell 连接到 system 数据库

    cypher-shell -u neo4j -p <password> -d system
  3. 创建 neo4j 数据库。

    对于 Neo4j 集群部署,您只需在其中一个集群服务器上运行 CREATE DATABASE name 命令。

    CREATE DATABASE neo4j;
  4. 打开浏览器访问 http://<external-ip>:7474/browser/,检查所有数据是否已成功恢复。

  5. neo4j 数据库执行 Cypher 命令,例如

    MATCH (n) RETURN n

    如果您在备份数据库时使用了 --include-metadata 选项,则可以手动恢复用户和角色元数据。更多信息,请参阅 恢复数据库备份 → 示例

要恢复 system 数据库,请按照 转储和加载数据库(离线) 中描述的步骤进行操作。

从传统备份迁移到云原生备份

要从基于持久卷的备份迁移到云原生备份,您需要遵循以下步骤

  1. 执行一次最终的传统备份,以确保拥有最新数据。更多信息,请参阅 准备将数据库备份到本地存储备份您的数据库

  2. 如果需要,将现有备份上传到云存储桶。您可以使用云提供商的 CLI 工具传输备份文件

    • 对于 AWS S3: aws s3 cp /path/to/backups s3://your-bucket/backups --recursive

    • 对于 Google Cloud Storage: gsutil cp -r /path/to/backups gs://your-bucket/backups

    • 对于 Azure Blob Storage: az storage blob upload-batch --source /path/to/backups --destination your-container

  3. 更新 backup-values.yaml 文件以配置云提供商、存储桶名称和凭据。有关详细信息,请参阅 准备将数据库备份到云提供商(AWS、GCP 和 Azure)存储桶

  4. 使用更新后的 backup-values.yaml 文件安装 neo4j-admin Helm chart,将数据库备份到云提供商存储桶。有关详细信息,请参阅 备份您的数据库