From the Longhorn UI, recurring snapshots and backups can be scheduled.
To set up a schedule, you will go to the volume detail view in Longhorn. Then you will set:
The type of schedule, either backup or snapshot
The time that the backup or snapshot will be created, in the form of a CRON expression
The number of backups or snapshots to retain
Any labels that should be applied to the backup or snapshot
Then Longhorn will automatically create snapshots or backups for the user at that time, as long as the volume is attached to a node.
If you want to set up recurring snapshots and backups even when the volumes are detached, see the section Allow Recurring Job While Volume Is Detached
Recurring snapshots can be configured using the Longhorn UI, or by using a Kubernetes StorageClass.
For more information on how snapshots and backups work, refer to the concepts section.
Note: To avoid the problem that recurring jobs may overwrite the old backups/snapshots with identical backups and empty snapshots when the volume doesn’t new data for a long time, Longhorn does the following:
Recurring backup job only takes a new backup when the volume has new data since the last backup.
Recurring snapshot job only takes a new snapshot when the volume has new data in the volume head (the live data).
Set up Recurring Jobs using the Longhorn UI
Recurring snapshots and backups can be configured from the volume detail page. To navigate to this page, click Volume, then click the name of the volume.
Set up Recurring Jobs using a StorageClass
Scheduled backups and snapshots can be configured in the recurringJobs parameters in a StorageClass.
Any future volumes created using this StorageClass will have those recurring jobs automatically set up.
The recurringJobs field should follow JSON format: