-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpostgresql-to-sftp.yaml
More file actions
78 lines (72 loc) · 2.48 KB
/
Copy pathpostgresql-to-sftp.yaml
File metadata and controls
78 lines (72 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# This is an example CronJob that backs up a postgresql database to
# an SFTP server, using a private key file and known_hosts file mounted
# from a secret.
apiVersion: batch/v1
kind: CronJob
metadata:
labels:
k8s-app: postgresql-to-sftp
name: daily-backup-to-sftp
spec:
# Run at 01:13 AM each day
schedule: 13 01 * * *
successfulJobsHistoryLimit: 3
failedJobsHistoryLimit: 1
jobTemplate:
spec:
template:
metadata:
labels:
k8s-app: postgresql-to-sftp
spec:
containers:
- name: backup
image: ghcr.io/gatenlp/postgresql-backup-rclone:latest
imagePullPolicy: Always
env:
# Postgresql connection parameters
- name: PGHOST
value: example-postgresql
- name: PGUSER
value: dbuser
- name: PGPASSWORD
valueFrom:
secretKeyRef:
key: password
name: postgres-credentials
# Name of the database or databases that we want to back up
- name: BACKUP_DATABASES
value: example_db
# Path on the server under which we want to save the backups.
# The dbuser must have write permission in this location.
- name: UPLOAD_PREFIX
value: /mnt/db-backups/daily
# Data store type is sftp
- name: RCLONE_CONFIG_STORE_TYPE
value: sftp
- name: RCLONE_CONFIG_STORE_SHELL_TYPE
value: none
# SFTP server name
- name: RCLONE_CONFIG_STORE_HOST
value: backups.example.com
# Username and key file for authentication
- name: RCLONE_CONFIG_STORE_USER
value: backupuser
- name: RCLONE_CONFIG_STORE_KEY_FILE
value: /ssh/key
# known_hosts file, used for the client to authenticate the server
- name: RCLONE_CONFIG_STORE_KNOWN_HOSTS_FILE
value: /ssh/known_hosts
# mount the key and known_hosts files at the required location
volumeMounts:
- mountPath: /ssh
name: ssh
readOnly: true
# Define the volume with the key and known_hosts files loaded from
# a secret
volumes:
- name: ssh
secret:
secretName: ssh-credentials
restartPolicy: Never
terminationGracePeriodSeconds: 30