https://github.com/fgeck/pbs-k8s-backup
Write backups of Kubernetes PVCs or Postgres Databases to a Proxmox Backup Server
https://github.com/fgeck/pbs-k8s-backup
backup kubernetes postgresql proxmox
Last synced: 6 months ago
JSON representation
Write backups of Kubernetes PVCs or Postgres Databases to a Proxmox Backup Server
- Host: GitHub
- URL: https://github.com/fgeck/pbs-k8s-backup
- Owner: fgeck
- Created: 2025-02-28T11:20:49.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2026-01-10T12:43:15.000Z (6 months ago)
- Last Synced: 2026-01-11T03:56:02.774Z (6 months ago)
- Topics: backup, kubernetes, postgresql, proxmox
- Language: Shell
- Homepage:
- Size: 193 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PBS Kubernetes Backup
A docker image which can be used to backup Pvcs or a Postgresql to PBS. Telegram notification will be sent on failure.
## How to use
### Backup Postgres
> [!IMPORTANT]
> Check the required environment variables in the respective Bash script. They must be passed to the container e.g. via secret.
Following CronJob will dump the postgres to a temp dir, upload the content to PBS and deletes the backup from the temp dir. The script will write to `/backup`.
```yaml
---
apiVersion: batch/v1
kind: CronJob
metadata:
name: default-postgres-backup
namespace: default
spec:
schedule: "0 23 * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: pbs-k8s-backup
image: ghcr.io/fgeck/pbs-k8s-backup:latest
env:
- name: BACKUP_NAME
value: "My-Postgresql"
envFrom:
- secretRef:
name: postgres-backup-secret
volumeMounts:
- name: temp-backup
mountPath: /backup
command: ["/entrypoint.sh", "postgres"]
restartPolicy: never
volumes:
- name: temp-backup
emptyDir:
sizeLimit: 6Gi
```
Result:

### Backups PVCs
> [!IMPORTANT]
> Check the required environment variables in the respective Bash script. They must be passed to the container e.g. via secret.
Running my Kubernetes Cluster with K3s and local-path-provisioner I wanted a CronJob that backups all my dynamically provisioned PVCs to PBS.
The script will cd into `PVC_HOST_PATH` and back up all directories found there. When using local-path-provisioner this info can be found in the ConfigMap `local-path-config`.
A CronJob would look as follows:
```yaml
---
apiVersion: batch/v1
kind: CronJob
metadata:
name: default-postgres-backup
namespace: default
spec:
schedule: "0 23 * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: pbs-k8s-backup
image: ghcr.io/fgeck/pbs-k8s-backup:latest
env:
- name: PROXMOX_BACKUP_SERVER_NAMESPACE
value: "k3s/pvcs"
- name: PVC_HOST_PATH
value: # e.g. /opt/k3s/pvcs
envFrom:
- secretRef:
name: postgres-backup-secret
volumeMounts:
- name: pvcs
mountPath: /pvcs
command: ["/entrypoint.sh", "pvcs"]
restartPolicy: never
volumes:
- name: pvcs
hostPath:
path: # e.g. /opt/k3s/pvcs
type: Directory
```
Result:
