Skip to content

Commit 45ae9bd

Browse files
authored
Merge pull request #320 from vshn/nextcloud/no_downtime_backup
Allow skipping maintenance mode for nextcloud backups
2 parents 8dde28f + 01a26e6 commit 45ae9bd

File tree

6 files changed

+43
-3
lines changed

6 files changed

+43
-3
lines changed

apis/vshn/v1/vshn_nextcloud.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,17 @@ type VSHNNextcloudSpec struct {
5555
WriteConnectionSecretToRef LocalObjectReference `json:"writeConnectionSecretToRef,omitempty"`
5656
}
5757

58+
type VSHNNextcloudBackupSpec struct {
59+
K8upBackupSpec `json:",inline"`
60+
61+
// +kubebuilder:default=false
62+
63+
// SkipMaintenance defines, if setting maintenance mode should be skipped during the backup. Defaults to false
64+
// Warning: If this is set to true, the maintenance mode will not be enabled during the backup. This might
65+
// lead to inconsistent backups.
66+
SkipMaintenance bool `json:"skipMaintenance,omitempty"`
67+
}
68+
5869
// VSHNNextcloudParameters are the configurable fields of a VSHNNextcloud.
5970
type VSHNNextcloudParameters struct {
6071
// Service contains nextcloud DBaaS specific properties
@@ -67,7 +78,7 @@ type VSHNNextcloudParameters struct {
6778
Scheduling VSHNDBaaSSchedulingSpec `json:"scheduling,omitempty"`
6879

6980
// Backup contains settings to control how the instance should get backed up.
70-
Backup K8upBackupSpec `json:"backup,omitempty"`
81+
Backup VSHNNextcloudBackupSpec `json:"backup,omitempty"`
7182

7283
// Restore contains settings to control the restore of an instance.
7384
Restore K8upRestoreSpec `json:"restore,omitempty"`

apis/vshn/v1/zz_generated.deepcopy.go

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crds/vshn.appcat.vshn.io_vshnnextclouds.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ spec:
6666
schedule:
6767
pattern: ^(\*|([0-9]|1[0-9]|2[0-9]|3[0-9]|4[0-9]|5[0-9])|\*\/([0-9]|1[0-9]|2[0-9]|3[0-9]|4[0-9]|5[0-9])) (\*|([0-9]|1[0-9]|2[0-3])|\*\/([0-9]|1[0-9]|2[0-3])) (\*|([1-9]|1[0-9]|2[0-9]|3[0-1])|\*\/([1-9]|1[0-9]|2[0-9]|3[0-1])) (\*|([1-9]|1[0-2])|\*\/([1-9]|1[0-2])) (\*|([0-6])|\*\/([0-6]))$
6868
type: string
69+
skipMaintenance:
70+
type: boolean
6971
type: object
7072
default: {}
7173
instances:

crds/vshn.appcat.vshn.io_xvshnnextclouds.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ spec:
110110
(\*|([0-9]|1[0-9]|2[0-3])|\*\/([0-9]|1[0-9]|2[0-3])) (\*|([1-9]|1[0-9]|2[0-9]|3[0-1])|\*\/([1-9]|1[0-9]|2[0-9]|3[0-1]))
111111
(\*|([1-9]|1[0-2])|\*\/([1-9]|1[0-2])) (\*|([0-6])|\*\/([0-6]))$
112112
type: string
113+
skipMaintenance:
114+
type: boolean
113115
type: object
114116
instances:
115117
default: 1

pkg/comp-functions/functions/vshnnextcloud/deploy.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,12 @@ func newValues(ctx context.Context, svc *runtime.ServiceRuntime, comp *vshnv1.VS
279279
"configs": map[string]string{
280280
"vshn-nextcloud.config.php": updatedNextcloudConfig,
281281
},
282+
"extraEnv": []map[string]any{
283+
{
284+
"name": "SKIP_MAINTENANCE",
285+
"value": strconv.FormatBool(comp.Spec.Parameters.Backup.SkipMaintenance),
286+
},
287+
},
282288
"extraInitContainers": extraInitContainers,
283289
"containerPort": 8080,
284290
"podSecurityContext": securityContext,

pkg/comp-functions/functions/vshnnextcloud/files/backup.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@ function disableMaintenance {
1010
sudo -u www-data /var/www/html/occ maintenance:mode --off 1>&2
1111
}
1212

13-
trap disableMaintenance EXIT
13+
if [ "$SKIP_MAINTENANCE" = false ]; then
1414

15-
sudo -u www-data /var/www/html/occ maintenance:mode --on 1>&2
15+
trap disableMaintenance EXIT
16+
17+
sudo -u www-data /var/www/html/occ maintenance:mode --on 1>&2
18+
fi
1619

1720
tar -cf - /var/www

0 commit comments

Comments
 (0)