From 3db2c084a23728daa00b731939f8befc78d23e0b Mon Sep 17 00:00:00 2001 From: pierre Date: Tue, 2 Jul 2024 14:56:40 +0100 Subject: [PATCH] change container to use alpine instead of curl --- ...loud_calendar_export_script.configmap.yaml | 14 +++++ Nextcloud/nextcloud-contact-backup.job.yaml | 52 ++++++++++++++++++ .../nextcloud_backup_calendar.cronjob.yaml | 55 +++++++++++++++++++ .../nextcloud_backup_contact.cronjob.yaml | 55 +++++++++++++++++++ .../nextcloud_backup_contact.cronjob.yaml.old | 53 ++++++++++++++++++ .../nextcloud_export_scripts.configmap.yaml | 23 ++++++++ 6 files changed, 252 insertions(+) create mode 100644 Nextcloud/Nextcloud_calendar_export_script.configmap.yaml create mode 100644 Nextcloud/nextcloud-contact-backup.job.yaml create mode 100644 Nextcloud/nextcloud_backup_calendar.cronjob.yaml create mode 100644 Nextcloud/nextcloud_backup_contact.cronjob.yaml create mode 100644 Nextcloud/nextcloud_backup_contact.cronjob.yaml.old create mode 100644 Nextcloud/nextcloud_export_scripts.configmap.yaml diff --git a/Nextcloud/Nextcloud_calendar_export_script.configmap.yaml b/Nextcloud/Nextcloud_calendar_export_script.configmap.yaml new file mode 100644 index 0000000..ca2dd5c --- /dev/null +++ b/Nextcloud/Nextcloud_calendar_export_script.configmap.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +data: + export_calendar.sh: | + #!/usr/bin/env bash + apk update + apk add curl + list='capgemini birmingham cesi papa blueberry personal-1 prometheus birthday maman capgemini_ca-gip shared_shared_by_calendar_sync' + for element in $list;do + curl -u $PI_USER_USERNAME:$PI_USER_PASSWORD https://nextcloud.tryton.geeraert.eu/remote.php/dav/calendars/pi/$element/\?export -o /backup/calendar_$element.ics + done + #curl -u $PI_USER_USERNAME:$PI_USER_PASSWORD https://nextcloud.tryton.geeraert.eu/remote.php/dav/calendars/pi/capgemini_ca-gip/\?export -o /backup/calendar.ics +kind: ConfigMap +metadata: + name: nextcloud-calendar-export-script diff --git a/Nextcloud/nextcloud-contact-backup.job.yaml b/Nextcloud/nextcloud-contact-backup.job.yaml new file mode 100644 index 0000000..c2599e9 --- /dev/null +++ b/Nextcloud/nextcloud-contact-backup.job.yaml @@ -0,0 +1,52 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: contact-backup + namespace: nextcloud +spec: + ttlSecondsAfterFinished: 100 + template: + spec: + containers: + - name: contact-backup + image: alpine + env: + - name: PI_USER_USERNAME + valueFrom: + secretKeyRef: + name: nextcloud-credentials + key: PI_USER_USERNAME + - name: PI_USER_PASSWORD + valueFrom: + secretKeyRef: + name: nextcloud-credentials + key: PI_USER_PASSWORD + command: ["/bin/sh","/config/export_calendar.sh"] + volumeMounts: + - name: calendar + mountPath: /backup + - name: scripts + mountPath: /config + volumes: + - name: calendar + persistentVolumeClaim: + claimName: calendar + - name: scripts + configMap: + name: nextcloud-calendar-export-script + defaultMode: 0555 + restartPolicy: Never + backoffLimit: 4 +--- +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: calendar + namespace: nextcloud +spec: + storageClassName: nfs-backup-storage-intelligent + accessModes: + - ReadWriteMany + resources: + requests: + storage: 2Gi diff --git a/Nextcloud/nextcloud_backup_calendar.cronjob.yaml b/Nextcloud/nextcloud_backup_calendar.cronjob.yaml new file mode 100644 index 0000000..4fe18ea --- /dev/null +++ b/Nextcloud/nextcloud_backup_calendar.cronjob.yaml @@ -0,0 +1,55 @@ +apiVersion: batch/v1 +kind: CronJob +metadata: + name: nextcloud-calendar-backup + namespace: nextcloud +spec: + schedule: "0 0 * * *" + jobTemplate: + spec: + ttlSecondsAfterFinished: 100 + template: + spec: + containers: + - name: calendar-backup + image: alpine + env: + - name: PI_USER_USERNAME + valueFrom: + secretKeyRef: + name: nextcloud-credentials + key: PI_USER_USERNAME + - name: PI_USER_PASSWORD + valueFrom: + secretKeyRef: + name: nextcloud-credentials + key: PI_USER_PASSWORD + command: ["/bin/sh","/config/export_calendars.sh"] + volumeMounts: + - name: calendar + mountPath: /backup + - name: scripts + mountPath: /config + volumes: + - name: calendar + persistentVolumeClaim: + claimName: calendar + - name: scripts + configMap: + name: nextcloud-export-scripts +# name: nextcloud-calendar-export-script + defaultMode: 0555 + restartPolicy: Never +--- +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: calendar + namespace: nextcloud +spec: + storageClassName: nfs-backup-storage-intelligent + accessModes: + - ReadWriteMany + resources: + requests: + storage: 2Gi diff --git a/Nextcloud/nextcloud_backup_contact.cronjob.yaml b/Nextcloud/nextcloud_backup_contact.cronjob.yaml new file mode 100644 index 0000000..8016929 --- /dev/null +++ b/Nextcloud/nextcloud_backup_contact.cronjob.yaml @@ -0,0 +1,55 @@ +apiVersion: batch/v1 +kind: CronJob +metadata: + name: nextcloud-contact-backup + namespace: nextcloud +spec: + schedule: "0 0 * * *" + jobTemplate: + spec: + ttlSecondsAfterFinished: 100 + template: + spec: + containers: + - name: contact-backup + image: alpine + env: + - name: PI_USER_USERNAME + valueFrom: + secretKeyRef: + name: nextcloud-credentials + key: PI_USER_USERNAME + - name: PI_USER_PASSWORD + valueFrom: + secretKeyRef: + name: nextcloud-credentials + key: PI_USER_PASSWORD + command: ["/bin/sh","/config/export_contacts.sh"] + volumeMounts: + - name: contact + mountPath: /backup + - name: scripts + mountPath: /config + volumes: + - name: contact + persistentVolumeClaim: + claimName: contact + - name: scripts + configMap: + name: nextcloud-export-scripts +# name: nextcloud-calendar-export-script + defaultMode: 0555 + restartPolicy: Never +--- +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: contact + namespace: nextcloud +spec: + storageClassName: nfs-backup-storage-intelligent + accessModes: + - ReadWriteMany + resources: + requests: + storage: 2Gi diff --git a/Nextcloud/nextcloud_backup_contact.cronjob.yaml.old b/Nextcloud/nextcloud_backup_contact.cronjob.yaml.old new file mode 100644 index 0000000..90d3167 --- /dev/null +++ b/Nextcloud/nextcloud_backup_contact.cronjob.yaml.old @@ -0,0 +1,53 @@ +apiVersion: batch/v1 +kind: CronJob +metadata: + name: nextcloud-contact-backup + namespace: nextcloud +spec: + schedule: "0 0 * * *" + jobTemplate: + spec: + ttlSecondsAfterFinished: 100 + template: + spec: + containers: + - name: contact-backup + image: alpine/curl + env: + - name: PI_USER_USERNAME + valueFrom: + secretKeyRef: + name: nextcloud-credentials + key: PI_USER_USERNAME + - name: PI_USER_PASSWORD + valueFrom: + secretKeyRef: + name: nextcloud-credentials + key: PI_USER_PASSWORD + args: + - -u + - $(PI_USER_USERNAME):$(PI_USER_PASSWORD) + - https://nextcloud.tryton.geeraert.eu/remote.php/dav/addressbooks/users/pi/contacts/?export + - -o + - /backup/contact.vcf + volumeMounts: + - name: contact + mountPath: /backup + volumes: + - name: contact + persistentVolumeClaim: + claimName: contact + restartPolicy: Never +--- +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: contact + namespace: nextcloud +spec: + storageClassName: nfs-backup-storage-intelligent + accessModes: + - ReadWriteMany + resources: + requests: + storage: 2Gi diff --git a/Nextcloud/nextcloud_export_scripts.configmap.yaml b/Nextcloud/nextcloud_export_scripts.configmap.yaml new file mode 100644 index 0000000..e08f38e --- /dev/null +++ b/Nextcloud/nextcloud_export_scripts.configmap.yaml @@ -0,0 +1,23 @@ +apiVersion: v1 +data: + export_calendars.sh: | + #!/usr/bin/env bash + apk update + apk add curl + list='capgemini Birmingham Cesi Papa Blueberry Personal Prometheus Birthday Maman Capgemini_CA-GIP Shared' + today_date=$(date "+%Y-%m-%d") + mkdir /backup/$today_date + for element in $list;do + curl -u $PI_USER_USERNAME:$PI_USER_PASSWORD https://nextcloud.tryton.geeraert.eu/remote.php/dav/calendars/pi/$element/\?export -o /backup/$today_date/calendar_$element.ics + done + export_contacts.sh: | + #!/usr/bin/env bash + apk update + apk add curl + today_date=$(date "+%Y-%m-%d") + mkdir /backup/$today_date + curl -u $PI_USER_USERNAME:$PI_USER_PASSWORD https://nextcloud.tryton.geeraert.eu/remote.php/dav/addressbooks/users/pi/contacts/?export -o /backup/$today_date/contact_$today_date.vcf +kind: ConfigMap +metadata: + creationTimestamp: null + name: nextcloud-export-scripts