-
Notifications
You must be signed in to change notification settings - Fork 0
/
postgresql-back.yaml
55 lines (54 loc) · 2.15 KB
/
postgresql-back.yaml
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
kind: CronJob
apiVersion: batch/v1beta1
metadata:
name: postgresql-back
namespace: klab
spec:
jobTemplate:
metadata:
labels:
app: postgresql-back
spec:
template:
metadata:
labels:
app: postgresql-back
spec:
restartPolicy: OnFailure
containers:
- name: postgresql-back
image: registry.cn-shanghai.aliyuncs.com/kcr-3rd/pgsqldump:v1
imagePullPolicy: IfNotPresent
env:
- name: POSTGRES_PASSWORD
value: postgres
- name: POSTGRES_ROOT_USER
value: "postgres" #admin权限的POSTGRES用户名
- name: PGPASSWORD
value: "postgres" #admin权限的用户名密码
- name: POSTGRES_HOST
value: "192.168.16.242" #POSTGRES数据库的host
- name: POSTGRES_PORT
value: "5432" #POSTGRES数据库的端口
- name: AWS_ACCESS_KEY_ID
value: "admin" #aws/minio的access_key
- name: AWS_SECRET_ACCESS_KEY
value: "icSJHfPKpN" #aws/minio的secret_key
- name: AWS_DEFAULT_REGION
value: "cn-northwest-1" #aws使用的存储区域,minio可以默认不动
- name: S3_ENDPOINT_URL
value: "http://192.168.16.103:9000" #aws/minio的url
- name: S3_BUCKETS
value: "heywhale" #存储数据使用的bucket_name
command:
- "/bin/sh"
- "-c"
- |
pg_dumpall -U $POSTGRES_ROOT_USER -h $POSTGRES_HOST -p $POSTGRES_PORT --inserts >/home/`date +%Y_%m_%d`.sql
aws s3 cp /home/`date +%Y_%m_%d`.sql s3://$S3_BUCKETS --endpoint $S3_ENDPOINT_URL
schedule: "\"0 1 * * *\""
concurrencyPolicy: Forbid
suspend: false
ttlSecondsAfterFinished: 100
successfulJobsHistoryLimit: 3
failedJobsHistoryLimit: 1