Skip to content

Commit

Permalink
feat: add aws backups
Browse files Browse the repository at this point in the history
  • Loading branch information
krtk6160 committed Nov 28, 2023
1 parent d3a6260 commit 69c9186
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 3 deletions.
12 changes: 9 additions & 3 deletions charts/galoy/templates/mongo-backup-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ data:
echo "Backup script starts"
set -e
LOG_TIME=$(date +%s)
BACKUP_NAME="$NETWORK-$LOG_TIME.gz"
BACKUP_NAME="$NETWORK-$LOG_TIME.gz"
echo "Backing up mongodb"
mongodump --host=$MONGODB_ADDRESS --port=$MONGODB_PORT --username=$MONGODB_USER --password=$MONGODB_PASSWORD --gzip --archive=$BACKUP_NAME -d=$MONGODB_DB --readPreference=secondary
Expand All @@ -24,12 +24,18 @@ data:
curl -X POST https://content.dropboxapi.com/2/files/upload --http1.1 --header "Authorization: Bearer $DROPBOX_ACCESS_TOKEN" --header "Dropbox-API-Arg: {\"path\": \"/mongo/$BACKUP_NAME\"}" --header "Content-Type: application/octet-stream" --data-binary $BACKUP_NAME
{{ end }}
{{ if .Values.galoy.trigger.backups.s3.enabled }}
export S3_BUCKET="{{ .Values.galoy.trigger.backups.s3.bucketName }}"
echo "Uploading backup $BACKUP_NAME to s3"
aws s3 cp $BACKUP_NAME s3://$S3_BUCKET/mongodb/$BACKUP_NAME
{{ end }}
{{ if .Values.galoy.trigger.backups.gcs.enabled }}
export BUCKET_NAME="{{ .Values.galoy.trigger.backups.gcs.bucketName }}"
export GCS_BUCKET="{{ .Values.galoy.trigger.backups.gcs.bucketName }}"
echo "Activating service account"
gcloud auth activate-service-account --key-file=$GOOGLE_APPLICATION_CREDENTIALS
echo "Uploading backup $BACKUP_NAME to gcs"
gsutil cp $BACKUP_NAME gs://$BUCKET_NAME/mongodb/$BACKUP_NAME 2>&1
gsutil cp $BACKUP_NAME gs://$GCS_BUCKET/mongodb/$BACKUP_NAME 2>&1
echo "Uploaded backup successfully"
{{ end }}
Expand Down
15 changes: 15 additions & 0 deletions charts/galoy/templates/trigger-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,21 @@ spec:
key: {{ .Values.galoy.trigger.backups.dropbox.accessTokenExistingSecret.key | quote }}
{{ end }}

{{ if .Values.galoy.trigger.backups.s3.enabled }}
- name: AWS_ACCESS_KEY_ID
valueFrom:
secretKeyRef:
name: {{ .Values.galoy.trigger.backups.s3.accessKeyExistingSecret.name | quote }}
key: {{ .Values.galoy.trigger.backups.s3.accessKeyExistingSecret.key | quote }}
- name: AWS_SECRET_ACCESS_KEY
valueFrom:
secretKeyRef:
name: {{ .Values.galoy.trigger.backups.s3.secretKeyExistingSecret.name | quote }}
key: {{ .Values.galoy.trigger.backups.s3.secretKeyExistingSecret.key | quote }}
- name: AWS_REGION
value: {{ .Values.galoy.trigger.backups.s3.region | quote }}
{{ end }}

{{ if .Values.galoy.api.firebaseNotifications.enabled }}
- name: GOOGLE_APPLICATION_CREDENTIALS
value: "/tmp/service-account.json"
Expand Down
23 changes: 23 additions & 0 deletions charts/galoy/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,29 @@ galoy:
name: dropbox-access-token
# Secret Key
key: token
## Backup data to S3 bucket
## To backup to S3 bucket, you would need an access key and secret key
## to upload data to your S3 bucket
##
s3:
# Enable/disable uploading backup to S3 bucket
enabled: false
# S3 bucket name to upload to (it should already be created)
bucketName: s3-bucket-name
# Aws region
region: us-east-1
# S3 access key to use to upload backup to above-mentioned bucket
accessKeyExistingSecret:
# Secret name
name: s3-creds
# Secret Key
key: access-key
# S3 secret key to use to upload backup to above-mentioned bucket
secretKeyExistingSecret:
# Secret name
name: s3-creds
# Secret Key
key: secret-key
## Configuration values for Galoy Admin components.
##
admin:
Expand Down

0 comments on commit 69c9186

Please sign in to comment.