Creare un backup e ripristinare i dati del blocco note
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Google Distributed Cloud (GDC) air-gapped ti consente di creare backup e ripristinare i dati dalla
home directory delle tue istanze JupyterLab.
Questa pagina descrive la creazione e il ripristino dei backup dei dati dei notebook Vertex AI Workbench. Se non hai mai utilizzato Vertex AI,
scopri di più su Vertex AI Workbench.
Prima di iniziare
Per ottenere le autorizzazioni necessarie per copiare i dati ripristinati, chiedi all'amministratore IAM dell'organizzazione di concederti il ruolo Sviluppatore cluster utente (user-cluster-developer).
Creare un backup e ripristinare i dati dell'istanza JupyterLab
Definisci le applicazioni protette per creare un backup della home directory di una singola istanza JupyterLab o delle home directory di tutte le istanze JupyterLab in un progetto contemporaneamente.
Crea una risorsa personalizzata ProtectedApplication nel cluster in cui vuoi pianificare i backup. I piani di backup e ripristino utilizzano le applicazioni protette per selezionare le risorse. Per informazioni sulla creazione di applicazioni protette, vedi
Strategie per le applicazioni protette.
La risorsa personalizzata ProtectedApplication contiene i seguenti campi:
Campo
Descrizione
resourceSelection
Il modo in cui l'oggetto ProtectedApplication seleziona le risorse per i backup o i ripristini.
type
Il metodo per selezionare le risorse. Un tipo Selector indica che devono essere selezionate le risorse con etichette corrispondenti.
selector
Le regole di selezione. Questo campo contiene i seguenti campi secondari:
matchLabels
Le etichette che l'oggetto ProtectedApplication utilizza per trovare le risorse corrispondenti. Questo campo contiene i seguenti campi secondari:
app.kubernetes.io/part-of
Il nome di un'applicazione di livello superiore di cui fa parte. Seleziona Vertex AI Workbench come applicazione di primo livello per le istanze JupyterLab.
app.kubernetes.io/component
Il componente all'interno dell'architettura. Seleziona le risorse di Vertex AI Workbench che forniscono spazio di archiviazione per le istanze JupyterLab.
app.kubernetes.io/instance
Un nome univoco che identifica l'istanza di un'applicazione. Restringi l'ambito per selezionare un'istanza JupyterLab. Il valore è uguale al nome dell'istanza JupyterLab nella console GDC.
Utilizza la risorsa personalizzata ProtectedApplication per selezionare lo spazio di archiviazione di una singola istanza JupyterLab o di tutte le istanze JupyterLab in un progetto, come nei seguenti esempi:
Seleziona lo spazio di archiviazione di una singola istanza JupyterLab:
L'esempio seguente mostra una risorsa personalizzata ProtectedApplication che
seleziona lo spazio di archiviazione per un'istanza JupyterLab denominata my-instance-name nello
spazio dei nomi my-project:
Seleziona lo spazio di archiviazione di tutte le istanze JupyterLab:
L'esempio seguente mostra una risorsa personalizzata ProtectedApplication che
seleziona lo spazio di archiviazione per tutte le istanze JupyterLab nello spazio dei nomi my-project:
[[["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\u003eGoogle Distributed Cloud (GDC) air-gapped allows for the creation of backups and restoration of data from the home directory of JupyterLab instances.\u003c/p\u003e\n"],["\u003cp\u003eA \u003ccode\u003eProtectedApplication\u003c/code\u003e custom resource is used to define which JupyterLab instances, or their storage, will be included in backup and restore operations.\u003c/p\u003e\n"],["\u003cp\u003eYou can create backups for a single JupyterLab instance or for all JupyterLab instances within a project by selecting the appropriate labels within the \u003ccode\u003eProtectedApplication\u003c/code\u003e custom resource.\u003c/p\u003e\n"],["\u003cp\u003eRestored data must be transferred to a new JupyterLab instance, as settings on the original \u003ccode\u003eNotebook\u003c/code\u003e custom resource are not backed up, and the process involves getting pod and image details, and creating a new pod for data access and copying.\u003c/p\u003e\n"],["\u003cp\u003eThe restored data is located in the \u003ccode\u003e/home/jovyan/restore\u003c/code\u003e directory of the new JupyterLab instance, accessible after transferring the data from the restored \u003ccode\u003ePersistentVolumeClaim\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# Create a backup and restore notebook data\n\nGoogle Distributed Cloud (GDC) air-gapped lets you create backups and restore data from the\nhome directory of your JupyterLab instances.\n\nThis page describes creating and restoring backups of Vertex AI Workbench\nnotebook data. If you are new to Vertex AI,\n[learn more about Vertex AI Workbench](/distributed-cloud/hosted/docs/latest/gdch/application/ao-user/vertex-ai-workbench-intro).\n| **Note:** Vertex AI Workbench doesn't support backing up the settings on the `Notebook` custom resource of the JupyterLab instance. You must create new JupyterLab instances and transfer the restored data into that instance.\n\nBefore you begin\n----------------\n\nTo get the permissions that you need to copy restored data, ask your\nOrganization IAM Admin to grant you the User Cluster\nDeveloper (`user-cluster-developer`) role.\n\nCreate a backup and restore JupyterLab instance data\n----------------------------------------------------\n\nDefine protected applications to create a backup of the home directory of an\nindividual JupyterLab instance or the home directories of all JupyterLab instances\nin a project at once.\n\nCreate a `ProtectedApplication` custom resource in the cluster where you want to\nschedule backups. Backup and restore plans use protected applications to select\nresources. For information about creating protected applications, see\n[Protected application strategies](/distributed-cloud/hosted/docs/latest/gdch/platform-application/pa-ao-operations/protected-application-strategies).\n\nThe `ProtectedApplication` custom resource contains the following fields:\n\nUse the `ProtectedApplication` custom resource to select the storage of a single\nJupyterLab instance or all JupyterLab instances in a project, as in the following\nexamples:\n\n- **Select the storage of a single JupyterLab instance**:\n\n The following example shows a `ProtectedApplication` custom resource that\n selects the storage for a JupyterLab instance named `my-instance-name` in\n the `my-project` namespace: \n\n apiVersion: gkebackup.gke.io/v1\n kind: ProtectedApplication\n metadata:\n name: my-protected-application\n namespace: my-project\n spec:\n resourceSelection:\n type: Selector\n selector:\n matchLabels:\n app.kubernetes.io/part-of: vtxwb\n app.kubernetes.io/component: storage\n app.kubernetes.io/instance: my-instance-name\n\n- **Select the storage of all JupyterLab instances**:\n\n The following example shows a `ProtectedApplication` custom resource that\n selects the storage for all JupyterLab instances in the `my-project` namespace: \n\n apiVersion: gkebackup.gke.io/v1\n kind: ProtectedApplication\n metadata:\n name: my-protected-application\n namespace: my-project\n spec:\n resourceSelection:\n type: Selector\n selector:\n matchLabels:\n app.kubernetes.io/part-of: vtxwb\n app.kubernetes.io/component: storage\n\n This example doesn't contain the `app.kubernetes.io/instance` label because\n it selects all JupyterLab instances.\n\nTo create a backup and restore data from a JupyterLab instance,\n[plan a set of backups](/distributed-cloud/hosted/docs/latest/gdch/platform-application/pa-ao-operations/plan-backups)\nand [plan a set of restores](/distributed-cloud/hosted/docs/latest/gdch/platform-application/pa-ao-operations/plan-restores)\nusing the `ProtectedApplication` custom resource you defined.\n\nCopy restored data to a new JupyterLab instance\n-----------------------------------------------\n\nFollow these steps to copy restored data from the `PersistentVolumeClaim`\nresource of a JupyterLab instance to a new JupyterLab instance:\n\n1. [Meet the prerequisites](#before-you-begin).\n2. [Create a JupyterLab notebook](/distributed-cloud/hosted/docs/latest/gdch/application/ao-user/vertex-ai-workbench#create-notebook) associated with a JupyterLab instance to copy restored data.\n3. Get the pod name of the JupyterLab instance where you created the notebook:\n\n kubectl get pods -l notebook-name=\u003cvar translate=\"no\"\u003eINSTANCE_NAME\u003c/var\u003e -n \u003cvar translate=\"no\"\u003ePROJECT_NAMESPACE\u003c/var\u003e\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eINSTANCE_NAME\u003c/var\u003e: the name of the JupyterLab instance you configured.\n - \u003cvar translate=\"no\"\u003ePROJECT_NAMESPACE\u003c/var\u003e: the project namespace where you created the JupyterLab instance.\n4. Get the name of the image that the JupyterLab instance is running:\n\n kubectl get pods \u003cvar translate=\"no\"\u003ePOD_NAME\u003c/var\u003e -n \u003cvar translate=\"no\"\u003ePROJECT_NAMESPACE\u003c/var\u003e -o jsonpath=\"{.spec.containers[0].image}\"\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003ePOD_NAME\u003c/var\u003e: the pod name of the JupyterLab instance.\n - \u003cvar translate=\"no\"\u003ePROJECT_NAMESPACE\u003c/var\u003e: the project namespace where you created the JupyterLab instance.\n5. Find the name of the `PersistentVolumeClaim` resource that was restored:\n\n kubectl get pvc -l app.kubernetes.io/part-of=vtxwb,app.kubernetes.io/component=storage,app.kubernetes.io/instance=\u003cvar translate=\"no\"\u003eRESTORED_INSTANCE_NAME\u003c/var\u003e -n \u003cvar translate=\"no\"\u003ePROJECT_NAMESPACE\u003c/var\u003e\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eRESTORED_INSTANCE_NAME\u003c/var\u003e: the name of the JupyterLab instance that you restored.\n - \u003cvar translate=\"no\"\u003ePROJECT_NAMESPACE\u003c/var\u003e: the project namespace where you created the JupyterLab instance.\n6. Create a YAML file named `vtxwb-data.yaml` with the following content:\n\n apiVersion: v1\n kind: Pod\n metadata:\n name: vtxwb-data\n namespace: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003ePROJECT_NAMESPACE\u003c/span\u003e\u003c/var\u003e\n labels:\n aiplatform.gdc.goog/service-type: workbench\n spec:\n containers:\n - args:\n - sleep infinity\n command:\n - bash\n - -c\n image: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eIMAGE_NAME\u003c/span\u003e\u003c/var\u003e\n imagePullPolicy: IfNotPresent\n name: vtxwb-data\n resources:\n limits:\n cpu: \"1\"\n memory: 1Gi\n requests:\n cpu: \"1\"\n memory: 1Gi\n terminationMessagePath: /dev/termination-log\n terminationMessagePolicy: File\n volumeMounts:\n - mountPath: /home/jovyan\n name: restore-data\n workingDir: /home/jovyan\n volumes:\n - name: restore-data\n persistentVolumeClaim:\n claimName: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eRESTORED_PVC_NAME\u003c/span\u003e\u003c/var\u003e\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003ePROJECT_NAMESPACE\u003c/var\u003e: the project namespace where you created the JupyterLab instance.\n - \u003cvar translate=\"no\"\u003eIMAGE_NAME\u003c/var\u003e: the name of the container image that the JupyterLab instance is running.\n - \u003cvar translate=\"no\"\u003eRESTORED_PVC_NAME\u003c/var\u003e: the name of the restored `PersistentVolumeClaim` resource.\n\n | **Note:** The name of the home directory of your JupyterLab instances is `/home/jovyan`.\n7. Create a new pod for your restored `PersistentVolumeClaim` resource:\n\n kubectl apply -f ./vtxwb-data --kubeconfig \u003cvar translate=\"no\"\u003eKUBECONFIG_PATH\u003c/var\u003e\n\n Replace \u003cvar translate=\"no\"\u003eKUBECONFIG_PATH\u003c/var\u003e with the path of the\n kubeconfig file in the cluster.\n8. Wait for the `vtxwb-data` pod to reach the `RUNNING` state.\n\n9. Copy your restored data to a new JupyterLab instance:\n\n kubectl cp \u003cvar translate=\"no\"\u003ePROJECT_NAMESPACE\u003c/var\u003e/vtxwb-data:/home/jovyan ./restore --kubeconfig \u003cvar translate=\"no\"\u003eKUBECONFIG_PATH\u003c/var\u003e\n\n kubectl cp ./restore \u003cvar translate=\"no\"\u003ePROJECT_NAMESPACE\u003c/var\u003e/\u003cvar translate=\"no\"\u003ePOD_NAME\u003c/var\u003e:/home/jovyan/restore --kubeconfig \u003cvar translate=\"no\"\u003eKUBECONFIG_PATH\u003c/var\u003e\n\n rm ./restore\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003ePROJECT_NAMESPACE\u003c/var\u003e: the project namespace where you created the JupyterLab instance.\n - \u003cvar translate=\"no\"\u003eKUBECONFIG_PATH\u003c/var\u003e: the path of the kubeconfig file in the cluster.\n - \u003cvar translate=\"no\"\u003ePOD_NAME\u003c/var\u003e: the pod name of the JupyterLab instance.\n\n After copying the data, your restored data is available in the\n `/home/jovyan/restore` directory.\n10. Delete the pod that you created to access your restored data:\n\n kubectl delete pod vtxwb-data -n my-namespace` --kubeconfig \u003cvar translate=\"no\"\u003eKUBECONFIG_PATH\u003c/var\u003e\n\n Replace \u003cvar translate=\"no\"\u003eKUBECONFIG_PATH\u003c/var\u003e with the path of the kubeconfig file in the cluster."]]