.. SPDX-FileCopyrightText: 2024 Univention GmbH
..
.. SPDX-License-Identifier: AGPL-3.0-only

.. _backup-restore-backup:

Backup
======

After :ref:`installing Velero <backup-restore-tool-install>`,
you're ready to create your backup.
This section describes how to create a backup
and how to get detailed information about it.
The backup covers the entire Kubernetes namespace where you have deployed Nubus.
It creates snapshots of the persistent volumes and stores information about the resources
in the S3-compatible object store.

.. important::

   For backup consistency,
   you need to run the database backup at the same time as the backup for Nubus.
   For the database backup, see :ref:`backup-restore-databases`.

.. _backup-restore-backup-create:

Create a backup
---------------

To create a full backup of all pods that Nubus for Kubernetes has deployed to the Nubus namespace,
follow these steps:

#. **Defining the settings for the backup**

   To define the namespace where Velero runs and which namespace of Nubus you want to include in the backup,
   see :numref:`backup-restore-create-backup-settings-listing`.

   .. code-block:: console
      :caption: Define settings for backup
      :name: backup-restore-create-backup-settings-listing

      $ export BACKUP_NAME="Name of your backup"
      $ export NAMESPACE_FOR_VELERO="your namespace for Velero"
      $ export NAMESPACE_FOR_NUBUS="your namespace including Nubus"

#. **Creating the backup**

   To create a backup and tell Velero
   to back up Nubus,
   run the command in :numref:`backup-restore-create-backup-listing`.

   .. code-block:: console
      :caption: Create a backup
      :name: backup-restore-create-backup-listing

      $ velero backup create "$BACKUP_NAME" \
          --namespace "$NAMESPACE_FOR_VELERO" \
          --include-namespaces "$NAMESPACE_FOR_NUBUS"

.. seealso::

   `Velero Docs - Backup Reference <https://velero.io/docs/v1.14/backup-reference/>`_
      for a reference of the backup command and how to schedule a backup.

.. _backup-restore-backup-describe:

Information about a backup
--------------------------

After you :ref:`create a backup <backup-restore-backup-create>`,
you can retrieve various information about it, as shown in this section.
To set the environment variables used,
see :numref:`backup-restore-create-backup-settings-listing`.

* To list all that backups that Velero has created so far,
  run the command in :numref:`backup-restore-backup-describe-get-listing`.

  .. code-block:: console
     :caption: List all backup from a Velero configuration and its storage provider
     :name: backup-restore-backup-describe-get-listing

     $ velero backup get --namespace "$NAMESPACE_FOR_VELERO"

* To view the details of a particular backup,
  run the command in :numref:`backup-restore-backup-describe-listing`.

  For ``$BACKUP_NAME``, use the name from the listing of backups retrieved
  in :numref:`backup-restore-backup-describe-get-listing`.

  .. code-block:: console
     :caption: Describe a backup
     :name: backup-restore-backup-describe-listing

     $ velero backup describe "$BACKUP_NAME" --namespace "$NAMESPACE_FOR_VELERO"

* For a detailed listing of all backup item operations, resources, and backup volumes,
  use the command in :numref:`backup-restore-backup-describe-details-listing`.

  For ``$BACKUP_NAME``, use the name from the listing of backups retrieved
  in :numref:`backup-restore-backup-describe-get-listing`.

  .. code-block:: console
     :caption: Show details of a backup
     :name: backup-restore-backup-describe-details-listing

     $ velero backup describe "$BACKUP_NAME" \
         --namespace "$NAMESPACE_FOR_VELERO" \
         --details
