Skip to content

Commit

Permalink
Merge pull request #772 from amazeeio/restic-backup-support
Browse files Browse the repository at this point in the history
add restic backup support:
  • Loading branch information
Schnitzel committed Nov 18, 2018
2 parents 6296c2b + 2fffe9c commit c97e380
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 7 deletions.
16 changes: 15 additions & 1 deletion images/oc-build-deploy-dind/build-deploy-docker-compose.sh
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,20 @@ else
done
fi

# If restic backups are supported by this cluster we create the schedule definition
if oc apply --insecure-skip-tls-verify customresourcedefinition schedules.backup.appuio.ch > /dev/null; then
TEMPLATE_PARAMETERS=()

BACKUP_SCHEDULE=$( /oc-build-deploy/scripts/convert-crontab.sh "${OPENSHIFT_PROJECT}" "H 0 * * *")
TEMPLATE_PARAMETERS+=(-p BACKUP_SCHEDULE="${BACKUP_SCHEDULE}")

PRUNE_SCHEDULE=$( /oc-build-deploy/scripts/convert-crontab.sh "${OPENSHIFT_PROJECT}" "H 3 * * *")
TEMPLATE_PARAMETERS+=(-p PRUNE_SCHEDULE="${PRUNE_SCHEDULE}")

OPENSHIFT_TEMPLATE="/oc-build-deploy/openshift-templates/backup/schedule.yml"
. /oc-build-deploy/scripts/exec-openshift-resources.sh
fi

if [ -f /oc-build-deploy/lagoon/${YAML_CONFIG_FILE}.yml ]; then
oc apply --insecure-skip-tls-verify -n ${OPENSHIFT_PROJECT} -f /oc-build-deploy/lagoon/${YAML_CONFIG_FILE}.yml
fi
Expand Down Expand Up @@ -594,7 +608,7 @@ do
OPENSHIFT_SERVICES_TEMPLATE="/oc-build-deploy/openshift-templates/${SERVICE_TYPE}/pvc.yml"
if [ -f $OPENSHIFT_SERVICES_TEMPLATE ]; then
OPENSHIFT_TEMPLATE=$OPENSHIFT_SERVICES_TEMPLATE
. /oc-build-deploy/scripts/exec-openshift-create-pvc.sh
. /oc-build-deploy/scripts/exec-openshift-resources.sh
fi

CRONJOB_COUNTER=0
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
apiVersion: v1
kind: Template
metadata:
creationTimestamp: null
name: lagoon-openshift-template-schedule
parameters:
- name: SERVICE_NAME
description: Name of this service
required: true
- name: SAFE_BRANCH
description: Which branch this belongs to, special chars replaced with dashes
required: true
- name: SAFE_PROJECT
description: Which project this belongs to, special chars replaced with dashes
required: true
- name: BRANCH
description: Which branch this belongs to, original value
required: true
- name: PROJECT
description: Which project this belongs to, original value
required: true
- name: LAGOON_GIT_SHA
description: git hash sha of the current deployment
required: true
- name: SERVICE_ROUTER_URL
description: URL of the Router for this service
value: ""
- name: OPENSHIFT_PROJECT
description: Name of the Project that this service is in
required: true
- name: REGISTRY
description: Registry where Images are pushed to
required: true
- name: BACKUP_SCHEDULE
description: Schedule of the Backup in Cron format
required: true
- name: PRUNE_SCHEDULE
description: Schedule of the Pruning in Cron format
required: true
objects:
- apiVersion: backup.appuio.ch/v1alpha1
kind: Schedule
metadata:
name: backup-schedule
spec:
backup:
keepJobs: 2
schedule: '${BACKUP_SCHEDULE}'
check:
schedule: 0 0 * * 0
prune:
retention:
keepDaily: 7
keepWeekly: 4
schedule: '${PRUNE_SCHEDULE}'
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ objects:
type: ${DEPLOYMENT_STRATEGY}
template:
metadata:
annotations:
appuio.ch/backupcommand: >-
mysqldump --all-databases -h $MARIADB_HOST -u $MARIADB_USERNAME
-p$MARIADB_PASSWORD
creationTimestamp: null
labels:
service: ${SERVICE_NAME}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ objects:
type: ${DEPLOYMENT_STRATEGY}
template:
metadata:
annotations:
appuio.ch/backupcommand: >-
mysqldump --all-databases -h $MARIADB_HOST -u $MARIADB_USERNAME
-p$MARIADB_PASSWORD
creationTimestamp: null
labels:
service: ${SERVICE_NAME}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ objects:
- apiVersion: v1
kind: PersistentVolumeClaim
metadata:
annotations:
appuio.ch/backup: "true"
name: ${SERVICE_NAME}
spec:
accessModes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ objects:
- apiVersion: v1
kind: PersistentVolumeClaim
metadata:
annotations:
appuio.ch/backup: "true"
name: ${SERVICE_NAME}
spec:
accessModes:
Expand Down
2 changes: 2 additions & 0 deletions images/oc-build-deploy-dind/openshift-templates/solr/pvc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ objects:
- apiVersion: v1
kind: PersistentVolumeClaim
metadata:
annotations:
appuio.ch/backup: "true"
name: ${SERVICE_NAME}
spec:
accessModes:
Expand Down

This file was deleted.

0 comments on commit c97e380

Please sign in to comment.