Files
git.limbosolutions.com/deploy/backups/cronjobs/backup-pbs.yaml
T

101 lines
4.2 KiB
YAML

apiVersion: batch/v1
kind: CronJob
metadata:
name: backup-pbs
namespace: git-limbosolutions-com
spec:
schedule: "0 1 * * *"
jobTemplate:
spec:
backoffLimit: 1
template:
metadata:
labels:
dbAccess: "true"
app: backup-pbs
backups.infra.limbosolutions.com/pbs: "true"
spec:
restartPolicy: Never
initContainers:
- name: postgres
image: postgres:latest
resources:
limits:
memory: "512Mi"
cpu: "500m"
requests:
memory: "256Mi"
cpu: "250m"
command: ["sh", "-c"]
args:
- "#echo \"INFO: Starting export\"\n. /root/.gitea-inline-config/database\nexport PGPASSWORD=$PASSWD\n#echo \"INFO: Exporting database\"\npg_dump -h gitea-postgresql.git-limbosolutions-com.svc.cluster.local -U $USER -d $NAME > /data/postgresql-export/db_backup.sql\nif [ $? -ne 0 ]; then\n echo \"ERROR: Exporting database failed\"\n exit 1\nfi \n#echo \"INFO: Exporting database finished\"\n"
volumeMounts:
- name: backup-run-data
mountPath: /data/postgresql-export
subPath: postgresql-export
- name: gitea-inline-config
mountPath: /root/.gitea-inline-config
readOnly: true
containers:
- name: pbs-client
### Maintained by flux - Image Update Automation
image: oci.limbosolutions.com/public/pbs-client:latest@sha256:8565b9d420051cdbd4a9054f29ada099d5c70554218aaed0078ec533117406fc # {"$imagepolicy": "git-limbosolutions-com:pbs-client"}
###
resources:
limits:
memory: "512Mi"
cpu: "500m"
requests:
memory: "256Mi"
cpu: "250m"
env:
- name: PBS_REPOSITORY
valueFrom:
secretKeyRef:
name: gitea-backup
key: PBS_REPOSITORY
- name: PBS_PASSWORD
valueFrom:
secretKeyRef:
name: gitea-backup
key: PBS_PASSWORD
- name: PBS_FINGERPRINT
valueFrom:
secretKeyRef:
name: gitea-backup
key: PBS_FINGERPRINT
command: ["bash", "-c"]
args:
- |
set -e
# while true; do
# sleep 1s
# done
SCRIPT_START_TIME=$(date +%s)
proxmox-backup-client backup gitea-data.pxar:/data/gitea-data postgresql-data.pxar:/data/postgresql-data postgresql-export.pxar:/data/postgresql-export --include-dev /data/postgresql-data --include-dev /data/postgresql-export --include-dev /data/gitea-data --backup-id "gitea-full" -ns git.limbosolutions.com
SCRIPT_DURATION=$(($(date +%s) - SCRIPT_START_TIME))
echo "INFO: Finished Backup of git.limbosolutions.com ($((SCRIPT_DURATION / 60 / 60)):$((SCRIPT_DURATION / 60)):$((SCRIPT_DURATION % 60))) "
volumeMounts:
- name: gitea-shared-storage
mountPath: /data/gitea-data
- name: db-postgresql-data
mountPath: /data/postgresql-data
- name: backup-run-data
mountPath: /data/postgresql-export
subPath: postgresql-export
- name: backup-run-data
mountPath: /tmp
subPath: tmp
volumes:
- name: gitea-shared-storage
persistentVolumeClaim:
claimName: gitea-shared-storage
- name: db-postgresql-data
persistentVolumeClaim:
claimName: data-gitea-postgresql-0
- name: backup-run-data
emptyDir: {}
- name: gitea-inline-config
secret:
secretName: gitea-inline-config