diff --git a/charts/portalmodelo/v0.5.0/templates/nfsbackup-pvc.yaml b/charts/portalmodelo/v0.5.0/templates/nfsbackup-pvc.yaml new file mode 100644 index 0000000..0f7c812 --- /dev/null +++ b/charts/portalmodelo/v0.5.0/templates/nfsbackup-pvc.yaml @@ -0,0 +1,15 @@ +{{- if and .Values.persistence.enabled .Values.repozo.enabled }} +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ include "portalmodelo.fullname" . }}-backupvol + labels: + {{- include "portalmodelo.labels" . | nindent 4 }} +spec: + accessModes: + - {{ .Values.persistence.accessMode }} + resources: + requests: + storage: {{ .Values.persistence.size }} + storageClassName: "{{ .Values.repozo.storageClass }}" +{{- end }} diff --git a/charts/portalmodelo/v0.5.0/templates/repozo-configmap.yaml b/charts/portalmodelo/v0.5.0/templates/repozo-configmap.yaml new file mode 100644 index 0000000..73944b2 --- /dev/null +++ b/charts/portalmodelo/v0.5.0/templates/repozo-configmap.yaml @@ -0,0 +1,61 @@ +{{- if and .Values.persistence.enabled .Values.repozo.enabled }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "portalmodelo.fullname" . }}-backupscript +data: + backup: |- + #!/plone/Python-2.7/bin/python + + import sys + sys.path[0:0] = [ + '/plone/buildout-cache/eggs/collective.recipe.backup-2.17-py2.7.egg', + '/plone/buildout-cache/eggs/zc.buildout-2.2.5-py2.7.egg', + '/plone/buildout-cache/eggs/zc.recipe.egg-1.3.2-py2.7.egg', + '/plone/buildout-cache/eggs/setuptools-7.0-py2.7.egg', + ] + + + import logging + loglevel = logging.INFO + from optparse import OptionParser + parser = OptionParser() + parser.add_option("-q", "--quiet", + action="store_false", dest="verbose", default=True, + help="don't print status messages to stdout") + parser.add_option("-n", "--no-prompt", + action="store_true", dest="no_prompt", default=False, + help="don't ask for any user confirmation") + (options, args) = parser.parse_args() + # Allow the user to make the script more quiet (say in a cronjob): + if not options.verbose: + loglevel = logging.WARN + logging.basicConfig(level=loglevel, + format='%(levelname)s: %(message)s') + + import collective.recipe.backup.main + + if __name__ == '__main__': + sys.exit(collective.recipe.backup.main.backup_main( + bin_dir='/plone/instance/bin', + storages=[{'backup_location': '/backup/backups', + 'blob_backup_location': '/backup/blobstoragebackups', + 'blob_snapshot_location': '/backup/blobstoragesnapshots', + 'blobdir': '/data/blobstorage', + 'datafs': '/data/filestorage/Data.fs', + 'snapshot_location': '/backup/snapshotbackups', + 'storage': '1'}], + keep={{ .Values.repozo.keep }}, + keep_blob_days={{ .Values.repozo.keepblobdays }}, + full=False, + verbose=False, + gzip=True, + only_blobs=False, + backup_blobs=True, + use_rsync=True, + gzip_blob=False, + pre_command='', + post_command='', + no_prompt=options.no_prompt, + )) +{{- end }} \ No newline at end of file diff --git a/charts/portalmodelo/v0.5.0/templates/repozo-cronjob.yaml b/charts/portalmodelo/v0.5.0/templates/repozo-cronjob.yaml new file mode 100644 index 0000000..57efe96 --- /dev/null +++ b/charts/portalmodelo/v0.5.0/templates/repozo-cronjob.yaml @@ -0,0 +1,74 @@ +{{- if .Values.instance.zeoclient }} +{{- if and .Values.persistence.enabled .Values.repozo.enabled }} +apiVersion: batch/v1beta1 +kind: CronJob +metadata: + name: {{ include "portalmodelo.fullname" . }}-repozo + labels: + {{- include "portalmodelo.labels" . | nindent 4 }} +spec: + # generate a random backup time between 1 and 5 AM + schedule: {{ mod (randNumeric 2) 60 }} {{ mod (randNumeric 1) 6 }} * * * + jobTemplate: + spec: + template: + metadata: + labels: + {{- include "portalmodelo.labels" . | nindent 12 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 12 }} + {{- end }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 12 }} + containers: + - name: {{ .Release.Name }}-repozo + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + securityContext: + runAsNonRoot: false + runAsUser: 0 + command: + - "/bin/bash" + - "-c" + args: + - "/plone/instance/bin/backup" + env: + - name: TZ + value: {{ .Values.portal.timeZone }} + volumeMounts: + - mountPath: /plone/instance/bin/backup + subPath: backup + name: backupscript + - mountPath: /data + name: data + - mountPath: /backup + name: backupvol + resources: + {{- toYaml .Values.resources.zeo | nindent 16 }} + restartPolicy: OnFailure + volumes: + - name: data + persistentVolumeClaim: + claimName: {{ include "portalmodelo.fullname" . }}-data + - name: backupvol + persistentVolumeClaim: + claimName: {{ include "portalmodelo.fullname" . }}-backupvol + - name: backupscript + configMap: + name: {{ include "portalmodelo.fullname" . }}-backupscript + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 12 }} + {{- end }} +{{- end}} +{{- end}} diff --git a/charts/portalmodelo/v0.5.0/values.yaml b/charts/portalmodelo/v0.5.0/values.yaml index 3de35d2..f8052a9 100644 --- a/charts/portalmodelo/v0.5.0/values.yaml +++ b/charts/portalmodelo/v0.5.0/values.yaml @@ -52,6 +52,12 @@ instance: schedule: "0 1 * * SUN" # Every Sunday at 1AM keepDays: 7 +repozo: + enabled: false + storageClass: nfs-backup + keep: 1 + keepblobdays: 14 + podAnnotations: {} podSecurityContext: {}