Personalizzare il backup e il ripristino per un'applicazione
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Questa pagina descrive come utilizzare le risorse ProtectedApplication per personalizzare il comportamento di backup e ripristino in Google Distributed Cloud (GDC) air-gapped.
I passaggi descritti in questa pagina sono facoltativi e non sono necessari per configurare correttamente il backup e il ripristino dei carichi di lavoro. Le risorse ProtectedApplication sono risorse Kubernetes facoltative negli spazi dei nomi che personalizzano il backup e il ripristino di singole applicazioni stateful. Senza risorse ProtectedApplication, si applicano le seguenti limitazioni:
Limiti la granularità dell'ambito di backup e ripristino al livello dello spazio dei nomi.
Durante l'esecuzione del backup non vengono eseguite operazioni di flush e quiescenza sui workload.Ciò potrebbe comportare che le macchine virtuali con più dischi non siano
coerenti in caso di arresto anomalo dopo il ripristino.
Le risorse ProtectedApplication sono risorse dello spazio dei nomi Kubernetes facoltative
utilizzate per personalizzare il backup e il ripristino di singole applicazioni stateful.
La risorsa ProtectedApplication definisce quali risorse Kubernetes appartengono a un'istanza dell'applicazione. Puoi configurare manualmente un'orchestrazione specializzata
utilizzando il comando kubectl per creare un backup e un ripristino di queste applicazioni nei seguenti
scenari:
Per identificare un insieme di risorse in uno spazio dei nomi di cui potrebbe essere eseguito il backup o il ripristino indipendentemente dalle altre risorse dello stesso spazio dei nomi. Un
ProtectedApplication è l'entità dello spazio dei nomi più granulare che
puoi identificare per un ambito di backup o ripristino.
Per fornire un'orchestrazione di backup specializzata ogni volta che
ProtectedApplication rientra nell'ambito di un backup. In particolare, se
ProtectedApplication contiene risorse PersistentVolumeClaim (PVC)
direttamente o tramite un modello di StatefulSet, puoi
eseguire hook prima e dopo il backup dei volumi. Gli hook sono comandi
eseguiti nei container delle applicazioni. Questi hook vengono spesso utilizzati per operazioni di scarico, sospensione o ripristino e forniscono un backup coerente con l'applicazione.
Prima di iniziare
Per utilizzare le risorse ProtectedApplication, devi disporre di:
Devi definire la risorsa ProtectedApplication prima di creare un piano di backup. Per ulteriori informazioni, vedi Pianificare un insieme di backup.
Il ruolo di identità e accesso necessario:
Per gli utenti con ruolo di amministratore della piattaforma:
Amministratore backup cluster utente: gestisce le risorse di backup come i piani di backup e ripristino nei cluster utente. Chiedi all'amministratore IAM dell'organizzazione di concederti il ruolo Amministratore backup cluster utente (user-cluster-backup-admin).
Per gli utenti con ruolo Operatore applicazione (AO):
Backup Creator: crea backup manuali ed esegue ripristini. Chiedi all'amministratore IAM del progetto di concederti il ruolo Autore backup (backup-creator).
Esegui il deployment delle risorse dell'applicazione protette
Ecco un esempio di specifica Deployment con una risorsa ProtectedApplication che esegue il backup
di tutte le risorse associate all'applicazione durante il backup e ripristina
tutte le risorse durante il ripristino:
Definisce come identificare le risorse che appartengono all'applicazione protetta:
type: Specifica uno dei seguenti valori:
ApplicationName: esegue il backup di un'applicazione sig-apps
all'interno dello stesso spazio dei nomi.
Selector: Esegue il backup delle risorse che corrispondono a un selettore specificato all'interno dello stesso spazio dei nomi.
applicationName: se type è
ApplicationName, specifica il nome dell'applicazione sig-apps
all'interno dello stesso spazio dei nomi.
selector: se type è
Selector, specifica il selettore di etichette
per selezionare le risorse all'interno dello stesso spazio dei nomi.
components
L'elenco dei componenti per l'applicazione protetta, come deployment o set con stato:
name: Il nome univoco del componente.
resourceKind: scegli tra Deployment o
StatefulSet.
resourceNames: l'elenco dei nomi che identificano
resourceKind nello spazio dei nomi.
strategy: Ulteriori dettagli su come eseguire il backup o
il ripristino di questo componente. Per ulteriori informazioni, consulta Strategie di protezione delle applicazioni.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-04 UTC."],[[["\u003cp\u003e\u003ccode\u003eProtectedApplication\u003c/code\u003e resources are optional Kubernetes resources used to customize the backup and restore process for individual stateful applications in Google Distributed Cloud (GDC) air-gapped.\u003c/p\u003e\n"],["\u003cp\u003eUsing \u003ccode\u003eProtectedApplication\u003c/code\u003e allows for fine-grained control over backup and restore scope at the application level, enabling independent backup and restore of specific sets of resources within a namespace.\u003c/p\u003e\n"],["\u003cp\u003eThese resources can facilitate specialized backup orchestration, including running hooks for flush and quiesce operations, leading to more application-consistent backups, especially for workloads with \u003ccode\u003ePersistentVolumeClaim\u003c/code\u003e (PVC) resources.\u003c/p\u003e\n"],["\u003cp\u003eTo utilize \u003ccode\u003eProtectedApplication\u003c/code\u003e, it must be defined before the creation of a backup plan, and users must have the necessary identity and access role permissions, such as User Cluster Backup Admin or Backup Creator.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eProtectedApplication\u003c/code\u003e resources use a \u003ccode\u003eresourceSelection\u003c/code\u003e field to identify the application resource, allowing it to use an \u003ccode\u003eApplicationName\u003c/code\u003e or \u003ccode\u003eSelector\u003c/code\u003e, additionally it has a \u003ccode\u003ecomponents\u003c/code\u003e field that allows to customize the backup process.\u003c/p\u003e\n"]]],[],null,["# Customize backup and restore for an application\n\nThis page describes how to use `ProtectedApplication` resources to customize the behavior of backup and restores in Google Distributed Cloud (GDC) air-gapped.\n\nThe steps described on this page are optional and are not required to successfully configure backup and restoration for your workloads. `ProtectedApplication` resources are optional Kubernetes resources in namespaces that customize the backup and restore of individual stateful applications. Without `ProtectedApplication` resources, the following restrictions apply:\n\n- You restrict the backup and restore scope granularity to the namespace level.\n- No flush and quiesce operations occur on workloads during backup execution.This might result in virtual machines with multiple disks not being crash-consistent after restoration.\n\n`ProtectedApplication` resources are optional Kubernetes namespace resources\nused to customize the backup and restore of individual stateful applications.\nThe `ProtectedApplication` resource defines which Kubernetes resources belong to\nan application instance. You can manually set up a specialized orchestration\nusing the `kubectl` command to create a backup and restore of those applications in the following\nscenarios:\n\n- To identify a set of resources in a namespace that might be backed up or restored independently of the other resources in that namespace. A `ProtectedApplication` is the most fine-grained namespace entity that you can identify for a backup or restore scope.\n- To provide specialized backup orchestration whenever the `ProtectedApplication` falls within the scope of a backup. In particular, if the `ProtectedApplication` contains `PersistentVolumeClaim` (PVC) resources either directly or through a template from a `StatefulSet`, you can run *hooks* before and after backing up the volumes. Hooks are commands that run in application containers. These hooks are often used for flush, quiesce, or unquiesce operations, and provide an application-consistent backup.\n\nBefore you begin\n----------------\n\nTo use `ProtectedApplication` resources, you must have the following:\n\n- You must define the `ProtectedApplication` resource before creating a backup plan. For more information, see [Plan a set of backups](/distributed-cloud/hosted/docs/latest/gdch/platform-application/pa-ao-operations/cluster-backup/plan-backups).\n- The necessary identity and access role:\n\n - For Platform Administrator (PA) users:\n - User Cluster Backup Admin: manages backup resources such as backup and restore plans in user clusters. Ask your Organization IAM Admin to grant you the User Cluster Backup Admin (`user-cluster-backup-admin`) role.\n - For Application Operator (AO) users:\n - Backup Creator: creates manual backups and restores. Ask your Project IAM Admin to grant you the Backup Creator (`backup-creator`) role.\n - For more information, see [Role definitions](/distributed-cloud/hosted/docs/latest/gdch/platform/pa-user/iam/role-definitions).\n\nDeploy protected application resources\n--------------------------------------\n\nHere is an example of a `Deployment` specification with a `ProtectedApplication` resource that backs up\nall of the resources associated with the application during backup, and restores\nall resources during the restore: \n\n apiVersion: v1\n kind: Namespace\n metadata:\n name: \"applications\"\n ---\n apiVersion: apps/v1\n kind: Deployment\n metadata:\n name: protected-application-deployment\n namespace: applications\n labels:\n app: protected\n spec:\n selector:\n matchLabels:\n app: nginx\n replicas: 2\n template:\n metadata:\n labels:\n app: nginx\n spec:\n containers:\n - name: nginx\n image: nginx:1.14.2\n ports:\n - containerPort: 80\n ---\n apiVersion: apps/v1\n kind: Deployment\n metadata:\n name: unprotected-application-deployment\n namespace: applications\n labels:\n app: unprotected\n spec:\n selector:\n matchLabels:\n app: nginx\n replicas: 2\n template:\n metadata:\n labels:\n app: nginx\n spec:\n containers:\n - name: nginx\n image: nginx:1.14.2\n ports:\n - containerPort: 80\n ---\n\n apiVersion: gkebackup.gke.io/v1\n kind: ProtectedApplication\n metadata:\n name: protected-application-test\n namespace: applications\n spec:\n applicationName: protectedApplication\n resourceSelection:\n type: Selector\n selector:\n matchLabels:\n app: protected\n components:\n - name: protect-application-deployment\n resourceKind: Deployment\n resourceNames:\n - protected-application-deployment\n strategy:\n type: BackupAllRestoreAll\n\nSpecify the `ProtectedApplication` in the list of\n`selectedApplications` in the `backupScope`. For example: \n\n apiVersion: backup.gdc.goog/v1\n kind: BackupPlan\n metadata:\n name: protected-application-backupplan-test\n namespace: applications\n spec:\n clusterName: \"cluster-sample\"\n backupSchedule:\n cronSchedule: \"*/30 * * * *\"\n paused: true\n backupConfig:\n backupScope:\n selectedApplications:\n namespacedNames:\n - name: protected-application-test\n namespace: applications\n backupRepository: \"backup-repository\"\n retentionPolicy:\n backupDeleteLockDays: 10\n backupRetainDays: 10\n\nThis example includes the following values:\n\nWhat's next\n-----------\n\n- To select a protected application strategy, see [Protected application strategies](/distributed-cloud/hosted/docs/latest/gdch/platform-application/pa-ao-operations/protected-application-strategies)."]]