Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ on:
- '**'
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*'
pull_request:
branches: [ master ]

jobs:
build-and-push:
Expand Down Expand Up @@ -38,9 +36,9 @@ jobs:
docker push ghcr.io/haosgames/restic-pg-dump-docker:${{ env.IMAGE_TAG }}

# If this is the master branch, also tag as latest
if [[ "${{ github.ref }}" == "refs/heads/master" ]]; then
docker tag ghcr.io/haosgames/restic-pg-dump-docker:${{ env.IMAGE_TAG }} ghcr.io/haosgames/restic-pg-dump-docker:latest
docker push ghcr.io/haosgames/restic-pg-dump-docker:latest
if [[ "${{ github.ref_type }}" == "branch" ]]; then
docker tag ghcr.io/haosgames/restic-pg-dump-docker:${{ env.IMAGE_TAG }} ghcr.io/haosgames/restic-pg-dump-docker:${{ github.ref_name }}
docker push ghcr.io/haosgames/restic-pg-dump-docker:${{ github.ref_name }}
fi

push-helmchart:
Expand Down
10 changes: 7 additions & 3 deletions bin/backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ fi

mkdir -p "/pg_dump"

# Dump individual databases directly to restic repository.
echo "Dumping database '$PGDATABASE'"
pg_dump -Fc -f /pg_dump/$PGDATABASE.dump $PGDATABASE || true # Ignore failures
if [[ "DO_FULL_BACKUP" == "true" ]]; then
echo "Dumping enitre instance"
pg_dumpall --clean --if-exists -f /pg_dump/$PGDATABASE.dumpall
else
echo "Dumping individual database '$PGDATABASE'"
pg_dump -Fc -f /pg_dump/$PGDATABASE.dump $PGDATABASE
fi

# echo "Dumping global objects for '$PGHOST'"
# pg_dumpall --file="/pg_dump/!globals.sql" --globals-only
Expand Down
2 changes: 2 additions & 0 deletions charts/backup/templates/backup-cronjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ spec:
env:
- name: DB_RESTIC_NAME
value: {{ $value.namespace}}-{{ $value.name }}
- name: DO_FULL_BACKUP
value: '{{ $value.fullBackup | default "false" | quote }}'
- name: PGHOST
valueFrom:
secretKeyRef:
Expand Down
3 changes: 2 additions & 1 deletion charts/backup/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
# dbAppConfig: cluster-example-app
# resticSecretName: restic-secret
# schedule: "0 0 * * *"
# fullBackup: false

image:
pullPolicy: IfNotPresent
tag: latest
tag: master
repo: ghcr.io/haosgames/restic-pg-dump-docker
2 changes: 2 additions & 0 deletions charts/restore/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
# snapshotID: latest
# jobIteration: 1

# Restore is not supported for backups made with pg_dumpall

imagePullPolicy: IfNotPresent
image:
pullPolicy: IfNotPresent
Expand Down
6 changes: 6 additions & 0 deletions test/helm-values-backup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ backups:
dbAppConfig: cluster-example-app
resticSecretName: restic-secret
schedule: "*/5 * * * *"
- name: example-full
namespace: default
dbAppConfig: cluster-example-app
resticSecretName: restic-secret
schedule: "*/5 * * * *"
fullBackup: true

extraVolumes:
- name: restic-test-repo
Expand Down
2 changes: 2 additions & 0 deletions test/kind-cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ kubectl delete cluster --ignore-not-found=true cluster-example cluster-restored
kubectl delete -f test/persistent-volume-claim.yaml --ignore-not-found=true
kubectl delete -f test/persistent-volume.yaml --ignore-not-found=true
kubectl delete -f test/restic-secret.yaml --ignore-not-found=true
kubectl delete -f test/restic-secret-full.yaml --ignore-not-found=true
helm uninstall backup --ignore-not-found=true
helm uninstall restore --ignore-not-found=true

Expand All @@ -24,6 +25,7 @@ sleep 10

# Apply resources
kubectl apply -f test/restic-secret.yaml
kubectl apply -f test/restic-secret-full.yaml
kubectl apply -f test/persistent-volume.yaml
kubectl apply -f test/persistent-volume-claim.yaml

Expand Down
10 changes: 10 additions & 0 deletions test/restic-secret-full.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: Secret
metadata:
name: restic-secret
namespace: default
data:
RESTIC_REPOSITORY: L3Jlc3RpYy10ZXN0LXJlcG8vZnVsbC1yZXBv
RESTIC_PASSWORD: bm90aGluZwo=
AWS_ACCESS_KEY_ID: ""
AWS_SECRET_ACCESS_KEY: ""