Esta seção aborda como configurar o backup e a recuperação do banco de dados do Cassandra
usando ssh e um sistema de arquivos em vez de usar o Google Cloud. Consulte também:
O que é o backup Cassandra e a recuperação com armazenamento personalizado?
A opção de backup com armazenamento personalizado armazena backups do seu banco de dados do Cassandra para arquivos compactados no sistema de arquivos de um servidor especificado. Os backups ocorrem de acordo com uma programação especificada por você no arquivo de modificações.
A conexão com o servidor é feita pelo SSH seguro.
Como configurar backups sem serviços do Cloud
As etapas a seguir incluem exemplos comuns de como concluir tarefas específicas, como criar um par
de chaves SSH. Use os métodos apropriados para a instalação.
Designe um servidor Linux ou Unix para seus backups. Esse servidor precisa ser acessível via SSH pelo
plano do ambiente de execução da Apigee híbrida. Ele deve ter armazenamento suficiente para seus backups.
Configure um servidor SSH ou verifique se há um servidor SSH seguro configurado.
Crie um par de chaves SSH e armazene o arquivo da chave privada em um caminho acessível no plano do
ambiente de execução híbrido. Use uma senha em branco para o par de chaves ou o backup falhará. Por exemplo:
ssh-keygen -t rsa -b 4096 -C exampleuser@example.com
Enter file in which to save the key (/Users/exampleuser/.ssh/id_rsa): $APIGEE_HOME/hybrid-files/certs/ssh_key
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in ssh_key
Your public key has been saved in ssh_key.pub
The key fingerprint is:
SHA256:DWKo334XMZcZYLOLrd/8HNpjTERPJJ0mc11UYmrPvSA exampleuser@example.com
The key's randomart image is:
+---[RSA 4096]----+
| +. ++X|
| . . o.=.*+|
| . o . . o==o |
| . . . =oo+o...|
| . S +E oo .|
| . . .. . o .|
| . . . . o.. |
| . ...o ++. |
| .. .. +o+. |
+----[SHA256]-----+
Crie uma conta de usuário no servidor de backup com o nome apigee. Verifique se
o novo usuário apigee tem um diretório principal em /home.
No servidor de backup, crie um diretório ssh no novo diretório
/home/apigee.
Copie a chave pública (ssh_key.pub no exemplo anterior) em um arquivo chamado
authorized_keys no novo diretório /home/apigee/ssh. Por exemplo:
cd /home/apigee
mkdir .sshcd .sshvi authorized_keys
No servidor de backup, crie um diretório de backup dentro do diretório
/home/apigee/. O diretório de backup pode ser qualquer diretório, desde que o usuário apigee tenha acesso
a ele. Por exemplo:
cd /home/apigee
mkdir cassandra-backup
Teste a conexão. Verifique se os pods do Cassandra podem se conectar ao
servidor de backup usando SSH:
Faça login no shell do pod do Cassandra. Por exemplo:
O nome do diretório de backup no servidor de backup. Precisa ser um diretório dentro de
home/apigee (o diretório de backup se chama cassandra_backup
na etapa em que você criou o diretório de backup).
backup:cloudProvider
HYBRID
A propriedade cloudProvider: "HYBRID" é obrigatória.
Em que YOUR_OVERRIDES_FILE é o caminho para o arquivo de substituição que você acabou de editar.
Configurar restauração
A restauração retira os dados do local de backup e os restaura em um novo
cluster do Cassandra com o mesmo número de pods. Nenhum dado é retirado do antigo cluster do
Cassandra.
As instruções de restauração abaixo são para implantações de região única que não
usam o Google Cloud Storage para backups. Para outras implantações, consulte:
Crie um novo namespace no cluster existente do Kubernetes que será usado para restaurar
a implantação do huntime híbrido. Não use o nome original do namespace no novo namespace.
Não use o namespace antigo para a restauração.
No diretório raiz da instalação híbrida, crie um novo
arquivo overrides-restore.yaml.
Copie a configuração completa do Cassandra do arquivo overrides.yaml
original para o novo overrides-restore.yaml. Por exemplo:
cp ./overrides.yaml ./overrides-restore.yaml
Adicione um elemento de namespace ao novo arquivo overrides-restore.yaml.
O nome do diretório de backup no servidor de backup.
Precisa ser um diretório dentro de
home/apigee (o diretório de backup se chama cassandra_backup
na etapa em que você criou o diretório de backup).
restore:cloudProvider
HYBRID
A propriedade cloudProvider: "HYBRID" é obrigatória.
restore:snapshotTimestamp
BACKUP_TO_RESTORE
O backup específico que você quer restaurar, especificado na
sintaxe do crontab padrão (não é permitido usar caracteres curinga).
Altere o rótulo app em qualquer nó do Cassandra no namespace antigo. Para isso, execute o
seguinte comando:
Crie uma nova implantação híbrida de ambiente de execução. Isso criará um novo cluster do Cassandra e começará
a restaurar os dados de backup no cluster:
./apigeectl init -f ../overrides-restore.yaml
./apigeectl apply -f ../overrides-restore.yaml
Após a conclusão da restauração, o tráfego precisa ser alternado para usar o cluster do
Cassandra no novo namespace. Execute os comandos a seguir para alternar o tráfego:
kubectl get rs -n OLD_NAMESPACE # look for the 'apigee-connect' replicaset
Quando a alternância de tráfego for concluída, é possível reconfigurar os backups no cluster restaurado
removendo a configuração restore e adicionando a configuração backup ao
arquivo overrides-restore.yaml. Substitua YOUR_RESTORE_NAMESPACE pelo
novo nome do namespace criado na etapa 1.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-08-28 UTC."],[[["\u003cp\u003eThis document provides instructions for configuring custom storage backups of the Cassandra database in Apigee hybrid version 1.4, which is end of life and should be upgraded.\u003c/p\u003e\n"],["\u003cp\u003eTo set up backups, a dedicated Linux or Unix server must be designated, accessible via SSH, with sufficient storage, and an SSH key pair with no passphrase is required for the connection.\u003c/p\u003e\n"],["\u003cp\u003eThe backup schedule and destination are configured in the \u003ccode\u003eoverrides.yaml\u003c/code\u003e file, where you specify the server's IP, storage directory, private key file path, and the use of \u003ccode\u003eHYBRID\u003c/code\u003e as the cloud provider.\u003c/p\u003e\n"],["\u003cp\u003eRestoring a backup involves creating a new namespace, a new \u003ccode\u003eoverrides-restore.yaml\u003c/code\u003e file with the original Cassandra configuration, and applying the configuration to create a new Cassandra cluster with the data from the designated backup.\u003c/p\u003e\n"],["\u003cp\u003eAfter the restore you must route traffic to the new cluster, and after this, the restore setup can be deleted and a backup setup can be made.\u003c/p\u003e\n"]]],[],null,["# Backup and recovery with custom storage\n\n| You are currently viewing version 1.4 of the Apigee hybrid documentation. **This version is end of life.** You should upgrade to a newer version. For more information, see [Supported versions](/apigee/docs/hybrid/supported-platforms#supported-versions).\n\n\nThis section discusses how to configure backup and recovery of your Cassandra database\nusing `ssh` and your file system instead of using Google Cloud. See also:\n\n- [Cassandra backup and recovery](/apigee/docs/hybrid/v1.4/backup-recovery)\n- [Cassandra datastore](/apigee/docs/hybrid/v1.4/what-is-hybrid#cassandra-datastore)\n\nWhat is Cassandra backup and recovery with custom storage?\n----------------------------------------------------------\n\n\nBackup with custom storage stores backups of your Cassandra database to compressed files in the file system of\na server you specify. Backups occur on a schedule you specify in your overrides file.\nThe connection to the server is by secure SSH.\n| **Note:** You must ensure there is enough space on the file system for the backups, and adjust the frequency of the backups to avoid unnecessarily filling the alloted storage space. Apigee does not dictate a retention policy for the backup files. You may want to create a retention policy for files appropriate to your installation.\n\nSetting up backups without Cloud Services\n-----------------------------------------\n\n\nThe following steps include common examples for completing specific tasks, like creating an SSH\nkey pair. Use the methods that are appropriate to your installation.\n\n\nThe procedure has the following parts:\n\n- [Set up the server and SSH](#server-ssh)\n- [Set the schedule and destination for backup](#overrides-backup)\n- [Set up for recovery](#overrides-restore)\n\n### Set up the server and SSH\n\n1. Designate a Linux or Unix server for your backups. This server must be reachable using SSH from your Apigee hybrid runtime plane. It must have enough storage for your backups.\n2. Set up an SSH server on the server, or ensure that it has a secure SSH server configured. **Caution:** For security purposes, make sure your SSH server is up to date.\n3. Create an SSH key pair and store the private key file in a path that is accessible from your hybrid runtime plane. **You must use a blank password for your key pair or the backup will fail** . For example: \n\n ssh-keygen -t rsa -b 4096 -C \u003cvar translate=\"no\"\u003eexampleuser@example.com\u003c/var\u003e\n Enter file in which to save the key (/Users/exampleuser/.ssh/id_rsa): $APIGEE_HOME/hybrid-files/certs/ssh_key\n Enter passphrase (empty for no passphrase):\n Enter same passphrase again:\n Your identification has been saved in ssh_key\n Your public key has been saved in ssh_key.pub\n The key fingerprint is:\n SHA256:DWKo334XMZcZYLOLrd/8HNpjTERPJJ0mc11UYmrPvSA exampleuser@example.com\n The key's randomart image is:\n +---[RSA 4096]----+\n | +. ++X|\n | . . o.=.*+|\n | . o . . o==o |\n | . . . =oo+o...|\n | . S +E oo .|\n | . . .. . o .|\n | . . . . o.. |\n | . ...o ++. |\n | .. .. +o+. |\n +----[SHA256]-----+\n\n4. Create a user account on the backup server with the name `apigee`. Make sure the new `apigee` user has a home directory under `/home`.\n5. On the backup server, create an `ssh` directory in the new `/home/apigee` directory.\n6. Copy the public key (`ssh_key.pub` in the previous example) into a file named `authorized_keys` in the new `/home/apigee/ssh` directory. For example: \n\n cd /home/apigee\n mkdir .ssh\n cd .ssh\n vi authorized_keys\n\n7. On your backup server, create a backup directory within the `/home/apigee/` directory. The backup directory can be any directory as long as the `apigee` user has access to it. For example: \n\n cd /home/apigee\n mkdir cassandra-backup\n\n8. Test the connection. You need to make sure that your Cassandra pods can connect to your backup server using SSH:\n 1. Log into the shell of your Cassandra pod. For example: \n\n ```\n kubectl exec -it -n apigee APIGEE_CASSANDRA_DEFAULT_0 -- /bin/bash\n ```\n\n\n Where \u003cvar translate=\"no\"\u003eAPIGEE_CASSANDRA_DEFAULT_0\u003c/var\u003e is the name of a Cassandra pod. Change this to\n the name of the pod you want to connect from.\n 2. Connect by SSH to your backup server, using the server IP address: \n\n ```\n ssh apigee@BACKUP_SERVER_IP\n ```\n | **Note:** You may see a warning at this point saying your server's fingerprint is unrecognized and asks if you would like to continue. For purposes of this test, this means you can successfully reach your backup server from your Cassandra pod. You do not need to continue.\n\n### Set the schedule and destination for backup\n\n\nYou set the schedule and destination for backups in your `overrides.yaml` file.\n\n1. Add the following parameters to your `overrides.yaml` file:\n\n ### Parameters\n\n ```actionscript-3\n cassandra:\n backup:\n enabled: true\n keyFile: \"\u003cvar translate=\"no\"\u003ePATH_TO_PRIVATE_KEY_FILE\u003c/var\u003e\"\n server: \"\u003cvar translate=\"no\"\u003eBACKUP_SERVER_IP\u003c/var\u003e\"\n storageDirectory: \"/home/apigee/\u003cvar translate=\"no\"\u003eBACKUP_DIRECTORY\u003c/var\u003e\"\n cloudProvider: \"HYBRID\" # required verbatim \"HYBRID\" (all caps)\n schedule: \"\u003cvar translate=\"no\"\u003eSCHEDULE\u003c/var\u003e\"\n ```\n\n ### Example\n\n ```actionscript-3\n cassandra:\n backup:\n enabled: true\n keyFile: \"/Users/exampleuser/apigee-hybrid/hybrid-files/service-accounts/private.key\"\n server: \"34.56.78.90\"\n storageDirectory: \"/home/apigee/cassbackup\"\n cloudProvider: \"HYBRID\"\n schedule: \"0 2 * * *\"\n ```\n\n\n Where:\n\n2. Use `apigeectl` to apply the backup configuration to the storage scope of your cluster: \n\n ```\n $APIGEECTL_HOME/apigeectl --datastore -f YOUR_OVERRIDES_FILE\n ```\n\n\n Where \u003cvar translate=\"no\"\u003eYOUR_OVERRIDES_FILE\u003c/var\u003e is the path to the overrides file you just edited.\n\n### Configure restore\n\n\nRestoration takes your data from the backup location and restores the data into a new\nCassandra cluster with the same number of nodes. No data is taken from the old Cassandra\ncluster.\n\n\nThe restoration instructions below are for single region deployments that do not\nuse Google Cloud Storage for backups. For other deployments, see the following:\n\n- For single region deployments that do use Google Cloud Storage for backups, see [Cassandra backup and recovery](/apigee/docs/hybrid/v1.4/backup-recovery).\n- For multi-region deployments, see [Multi-region deployment on GKE and GKE on-prem](/apigee/docs/hybrid/v1.4/multi-region).\n\n\nTo restore Cassandra backups:\n\n1. Create a new namespace within the existing Kubernetes cluster that will be used to restore the hybrid huntime deployment. Do not use the original namespace name for the new namespace. Do not use the old namespace for restoration.\n2. In the root hybrid installation directory, create a new `overrides-restore.yaml` file.\n3. Copy the complete Cassandra configuration from your original `overrides.yaml` file into the new `overrides-restore.yaml` file. For example: \n\n ```\n cp ./overrides.yaml ./overrides-restore.yaml\n ```\n4. Add a namespace element to the new `overrides-restore.yaml` file.\n\n ### Parameters\n\n ```actionscript-3\n namespace: YOUR_RESTORE_NAMESPACE\n cassandra:\n ...\n restore:\n enabled: true\n keyFile: \"\u003cvar translate=\"no\"\u003ePATH_TO_PRIVATE_KEY_FILE\u003c/var\u003e\"\n server: \"\u003cvar translate=\"no\"\u003eBACKUP_SERVER_IP\u003c/var\u003e\"\n storageDirectory: \"/home/apigee/\u003cvar translate=\"no\"\u003eBACKUP_DIRECTORY\u003c/var\u003e\"\n cloudProvider: \"HYBRID\" # required verbatim \"HYBRID\" (all caps)\n snapshotTimestamp: \"\u003cvar translate=\"no\"\u003eBACKUP_TO_RESTORE\u003c/var\u003e\"\n ...\n ```\n\n ### Example\n\n ```actionscript-3\n namespace: cassandra-restore\n cassandra:\n restore:\n enabled: true\n keyFile: \"/Users/exampleuser/apigee-hybrid/hybrid-files/service-accounts/private.key\"\n server: \"34.56.78.90\"\n storageDirectory: \"/home/apigee/cassbackup\"\n cloudProvider: \"HYBRID\"\n snapshotTimestamp: \"20201001183903\"\n ```\n5. Where:\n\n6. Change the `app` label on any Cassandra nodes in the old namespace by executing the following command: \n\n ```\n kubectl label pods --overwrite --namespace=OLD_NAMESPACE -l app=apigee-cassandra app=apigee-cassandra-old\n ```\n7. Create a new hybrid runtime deployment. This will create a new Cassandra cluster and begin restoring the backup data into the cluster: \n\n ```\n ./apigeectl init -f ../overrides-restore.yaml\n ``` \n\n ```\n ./apigeectl apply -f ../overrides-restore.yaml\n ```\n8.\n Once the restoration is complete, the traffic must be switched to use the Cassandra\n cluster in the new namespace. Run the following commands to switch the traffic:\n\n ```\n kubectl get rs -n OLD_NAMESPACE # look for the 'apigee-connect' replicaset\n ``` \n\n ```\n kubectl patch rs -n OLD_NAMESPACE APIGEE_CONNECT_RS_NAME -p '{\"spec\":{\"replicas\" : 0}}'\n ```\n9. Once the traffic switch is complete, you can reconfigure backups on the restored cluster by removing the `restore` configuration and adding the `backup` configuration to the `overrides-restore.yaml` file. Replace \u003cvar translate=\"no\"\u003eYOUR_RESTORE_NAMESPACE\u003c/var\u003e with the new namespace name created in [step 1](#create-namespace). \n\n ```actionscript-3\n namespace: YOUR_RESTORE_NAMESPACE\n cassandra:\n ...\n backup:\n enabled: true\n serviceAccountPath: SA_JSON_FILE_PATH\n dbStorageBucket: CLOUD_STORAGE_BUCKET_PATH\n schedule: BACKUP_SCHEDULE_CODE\n ...\n ```\n\n\n Then apply the `backup` configuration with the following command: \n\n ```\n ./apigeectl apply -f ../overrides-restore.yaml\n ```"]]