Repository navigation
Multiple restores required to restore all pods with FS backup #9742
Replies: 1 comment
|
The issue with your JupyterHub setup is that Velero's FS backup (restic/kopia) only backs up PVCs that are mounted by running pods at backup time. If a user's pod isn't running when the backup happens, its PVC gets skipped. For this kind of workload, I'd switch to CSI snapshots instead of FS backup. CSI volume snapshots capture the PV directly regardless of whether a pod is mounting it. You'd need a CSI driver that supports snapshots (most cloud providers do), and then set If CSI snapshots aren't an option, another approach is to run a pre-backup hook that temporarily scales up all user pods (or a dummy pod that mounts each PVC) so they're running during the backup window. Ugly, but it works. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hello,
looking for advice how to best solve our scenario:
Our K8s cluster runs a fleet of application pods, each mounting exactly one PVC/PV with a block storage as backend. However by design of our application, it's never the case that all these pods are running at the same time because one pod exposes one app for one user with their individual data stored on the volume. When the user starts using the app, a new pod is created and "their" PVC is mounted and once the user stops using their app, its pod is removed after some hours of inactivity. Therefore the lifecycle of the pods follows typical office hours with many pods running during the day and less at night or weekends. We use FS backup scheduled every 6 hours to backup all pods running at that moment.
When restoring on a new cluster, our general strategy is to first restore the latest
Backupwith all itsPodVolumeBackups, then move on to the 2nd latestBackupand restore all pods included there etc. etc. . We've been using this command so far:velero restore create --from-backup $BACKUP_NAME --include-namespaces <namespace> --include-resources persistentvolumeclaims,persistentvolumes,pods -n veleroAll pods restored so far are kept running so that they will be skipped when the next backup is restored where any of these pods was backuped too. After n restores and once we know that all pods and their volumes were restored we can finally delete all pods. This requires us to temporarily scale up the number of nodes which can schedule these pods to a higher number than during regular operations but that's okay (I could open another discussion if this could be avoided but it's not the focus here).
The real issue is that once the first
Restoreis applied, all PVCs and PVs get restored but most of these PVCs don't have their pod included in thatRestore. For example initially we restore >100 PVCs/PVs but only <20 pods associated with those volumes (because <20 pods were running at the time of theBackup). Velero seems to be not able to understand that the PVs already restored must be replaced and we ran intoFailedAttachVolumeerrors on following applies ofRestoreswhen a Pod was attempted to be restored whose PV was recreated by a previousRestore. We then figured out that we have to delete all PVCs/PVs not associated with a running pod yet before applying the next olderBackup. We identify those PVs and PVCs by their label keyvelero.io/backup-nameand delete those PVCs and PVsand delete all their PVCs too which end up in. Then we can finally apply the next olderLoststateRestoresafely.We would like to minimize the friction of creating many
Restoreswhich include FS backups. Some thoughts on this:velero restore createwithout including PVs but that doesn't seem to trigger the FS restore process. Then the PVCs reference a PV in theirspecwhich doesn't exist and pods won't startRestore. Or in other words, don't restore PVC/PV if not referenced by aPodVolumeBackup. But I don't know if this is possible.--selector. The pods and PVCs have labels to uniquely identify them but our PVs don't have such labels. Also then we would need to apply eachBackuptimes every pod to restore and would need to lookup before restoring what pods are included in the restore and only restore those. So using selectors would also add overhead.We've only been using
velero restore createso far as interface to create restores. But I don't know if there's a safe and user friendly alternative to using Velero CLI to createRestores.Our cloud provider supports volume snapshots too but we prefer using FS backup to store the backups in a different region so we definitely want to stick to FS backups.
Velero versions - Client:
v1.18.0, Server:v1.18.0.File system backup backend: Kopia
Kubernetes cluster version:
1.33.4All reactions