Your cloud provider may have native ways to back up your Kubernetes cluster and volumes.
This guide describes how you would manually obtain the data you need to repopulate your Nebari instance if your cluster is lost, and you wish to start it up again from the nebari-config.yaml
file.
There are three main locations that you need to back up:
The Network File System (NFS) volume where all JupyterLab workspace files are stored
The JupyterHub database (for Dashboard configuration)
With kubectl configured, the next step will be to deploy the pod that allows you to access the cluster files. First, save the following pod specification to a file named
pod.yaml:
kind:Pod
apiVersion:v1
metadata:
name:volume-debugger-ubuntu
namespace:dev
spec:
volumes:
-name:volume-to-debug-ubuntu
persistentVolumeClaim:
claimName:"jupyterhub-dev-share"
containers:
-name:debugger
image:ubuntu
command:["sleep","36000"]
volumeMounts:
-mountPath:"/data"
name:volume-to-debug-ubuntu
Note in QHub versions before v0.4 replace claimName: "jupyterhub-dev-share" with claimName: "nfs-mount-dev-share" above.
Once the file pod.yml has been created, run the following command:
Terminal window
kubectlapply-fpod.yaml-ndev
If you have a namespace other than the default dev, replace dev with your namespace when running kubectl. To get a shell to this running pod, run:
The last line in the command above prompts for your AWS public/private key and default region. Paste each of these and press enter. To ignore and skip the output, press enter.
The preferred naming scheme includes a year-month-day, example 2021-04-23_home_backup.tar. You can utilize multi-backups through this step. This step takes several minutes
depending on the size of the home directories.
The last step is to extract the contents of the tarball:
Terminal window
cd/data
tar-xvf2021-04-23.tar
The file permissions for the default tar is same as the original files.
Important: If upgrading from 0.3.14 or earlier to 0.4 or later
QHub v0.4: If restoring your NFS as part of the upgrade you must also run some extra commands, immediately after extracting from the tar file.
Previous versions contained the shared folder within home. From 0.4.0 both shared and home directories are at the same level with respect to the QHub filesystem:
To do a backup on Google Cloud provider, install the gsutil CLI instead of the AWS CLI. Otherwise, the instructions are the same as
for AWS above, other than when working with S3. Here are the commands to access Google Spaces instead of S3 for copy/download of the backup:
To do a backup on Azure, first install Azure CLI and azcopy. You must also have setup a storage container with blob storage. Otherwise, the instructions are the same as for AWS above, other than when working with S3. Here are the commands to access Azure blob storage instead of S3 for copy/download of the backup.
The JupyterHub database will mostly be recreated whenever you start a new cluster, but should be backed up to save Dashboard configurations.
You want to do something very similar to the NFS backup, above - this time you need to back up one file located in the PersistentVolumehub-db-dir.
First, you might think you can make a new pod.yaml file, this time specifying claimName: "hub-db-dir" instead of
claimName: "jupyterhub-dev-share". However, hub-db-dir
is 'Read Write Once' - the 'Once' meaning it can only be mounted to one pod at a time
but the JupyterHub pod will already have this mounted! So the same approach will not work here.
Instead of mounting to a new 'debugger pod' you have to access the JupyterHub pod directly using the kubectl CLI.
Now you need to upload the file to S3. You might want to install the AWS CLI tool as we did before, however, as the Hub container is a rather restricted
environment the recommended approach is to upload files to AWS S3 buckets using curl.
For more details please refer to the [using curl to access AWS S3 buckets] documentation.
Nebari provides a script to export the important user/group database. Your new Nebari cluster will recreate a lot of Keycloak config (including new Keycloak clients which will
have new secrets), so only the high-level Group and User info is exported.
If you have a heavily customized Keycloak configuration, some details may be omitted in this export.
Locate your nebari-config.yaml file, for example by checking out of your Git repo for you Nebari. Activate a virtual environment with the nebari Python package installed.
This assumes that the password visible in the nebari-config.yaml file under the security.keycloak.initial_root_password field is still valid for the root user.
If not, first set the KEYCLOAK_ADMIN_PASSWORD environment variable to the new value.
To re-import your users and groups, [login to the /auth/ URL] using the root username and password.
Under 'Manage' on the left-hand side, click 'Import'. Locate the exported-keycloak.json file and select it. Then click the 'Import' button.
All users and groups should now be present in Keycloak. Note that the passwords will not have been restored, so you may need to be reset them after this step.