Backup Longhorn System

Longhorn System Backup Bundle

Longhorn system backup creates a resource bundle and uploads it to the remote backup target.

It includes below resources associating with the Longhorn system:

  • ClusterRoles
  • ClusterRoleBindings
  • ConfigMaps
  • CustomResourceDefinitions
  • DaemonSets
  • Deployments
  • EngineImages
  • PersistentVolumes
  • PersistentVolumeClaims
  • PodSecurityPolicies
  • RecurringJobs
  • Roles
  • RoleBindings
  • Settings
  • Services
  • ServiceAccounts
  • StorageClasses
  • Volumes

Warning: Longhorn does not backup BackingImages. We will improve this part in the future. See Restore Longhorn System - Prerequisite for restoring volumes created with the backing image.

Note: Longhorn does not backup Nodes. The Longhorn manager on the target cluster is responsible for creating its own Longhorn Node custom resources.

Note: Longhorn system backup bundle only includes resources operated by Longhorn.
Here is an example of a cluster workload with a bare Pod workload. The system backup will collect the PersistentVolumeClaim, PersistentVolume, and Volume. The system backup will exclude the Pod during system backup resource collection.

Create Longhorn System Backup

You can create a Longhorn system backup using the Longhorn UI. Or with the kubectl command.

Prerequisite

  • Set the backup target. Longhorn saves the system backups to the remote backup store. You will see an error during creation when the backup target is unset.

    Note: Unsetting the backup target clears the existing SystemBackup custom resource. Longhorn syncs to the remote backup store after setting the backup target. Another cluster can also sync to the same list of system backups when the backup target is the same.

  • Create a backup for all volumes (optional).

    Note: Longhorn system restores volume with the latest backup. The system backup does not trigger volume backup. We suggest updating all volumes’ last backup. Taking volume backups ensures the data is up-to-date with the system backup.

Using Longhorn UI

  1. Go to the System Backup page in the Setting drop-down list.
  2. Click Create under System Backup.
  3. Give a Name for the system backup.
  4. The system backup will be ready to use when the state changes to Ready.

Using kubectl Command

  1. Execute kubectl create to create a Longhorn SystemBackup custom resource.

    1. apiVersion: longhorn.io/v1beta2
    2. kind: SystemBackup
    3. metadata:
    4. name: demo
    5. namespace: longhorn-system
  2. The system backup will be ready to use when the state changes to Ready.

    1. > kubectl -n longhorn-system get systembackup
    2. NAME VERSION STATE CREATED
    3. demo v1.4.0 Ready 2022-11-24T04:23:24Z

Delete Longhorn System Backup

You can delete the Longhorn system backup in the remote backup target using the Longhorn UI. Or with the kubectl command.

Using Longhorn UI

  1. Go to the System Backup page in the Setting drop-down list.

  2. Delete a single system backup in the Operation drop-down menu next to the system backup. Or delete in batch with the Delete button.

    Note: Deleting the system backup will also make a deletion in the backup store.

Using kubectl Command

  1. Execute kubectl delete to delete a Longhorn SystemBackup custom resource.

    1. > kubectl -n longhorn-system get systembackup
    2. NAME VERSION STATE CREATED
    3. demo v1.4.0 Ready 2022-11-24T04:23:24Z
    4. > kubectl -n longhorn-system delete systembackup/demo
    5. systembackup.longhorn.io "demo" deleted

History

Original Feature Request

Available since v1.4.0


© 2019-2023 Longhorn Authors | Documentation Distributed under CC-BY-4.0

© 2023 The Linux Foundation. All rights reserved. The Linux Foundation has registered trademarks and uses trademarks. For a list of trademarks of The Linux Foundation, please see our Trademark Usage page.