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 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
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 section.
Scheduled backups and snapshots can be configured in the 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:
The following parameters should be specified for each recurring job:
name
: Name of one job. Do not use duplicate name in one . And the length ofname
should be no more than 8 characters.cron
: Cron expression. It tells execution time of one job.
Longhorn provides the setting allow-recurring-job-while-volume-detached
that allows you to do recurring backup even when a volume is detached. You can find the setting in Longhorn UI.
When the setting is enabled, Longhorn will automatically attach the volume and take snapshot/backup when it is the time to do recurring snapshot/backup.
Note that during the time the volume was attached automatically, the volume is not ready for the workload. Workload will have to wait until the recurring job finishes.