-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrw-backup-postgres-database.yml
More file actions
82 lines (65 loc) · 1.69 KB
/
rw-backup-postgres-database.yml
File metadata and controls
82 lines (65 loc) · 1.69 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
78
79
80
81
82
name: RW — Backup postgres database
on:
workflow_call:
inputs:
github_env:
type: string
database_host:
type: string
required: true
database_name:
type: string
required: true
database_user:
type: string
required: true
options:
type: string
required: false
storage_account_name:
type: string
required: true
storage_container_name:
type: string
required: true
backup_file_name:
type: string
required: true
secrets:
database_password:
required: true
azure_login_creds:
required: true
defaults:
run:
shell: bash
jobs:
backup:
name: 'Backup database'
runs-on: ubuntu-latest
environment:
name: ${{ inputs.github_env }}
steps:
- name: Create
run: |
PGPASSWORD='${{ secrets.database_password }}' pg_dump \
-h ${{ inputs.database_host }} \
-U ${{ inputs.database_user }} \
-Fc -v --no-owner --no-privileges \
${{ inputs.options }} \
-f postgres_backup.sql \
${{ inputs.database_name }}
- name: Azure login
uses: Azure/login@v1
with:
creds: '${{ secrets.azure_login_creds }}'
- name: Upload
uses: azure/CLI@v1
with:
azcliversion: 2.30.0
inlineScript: |
az storage blob upload \
--account-name ${{ inputs.storage_account_name }} \
--container-name ${{ inputs.storage_container_name }} \
--file postgres_backup.sql \
--name ${{ inputs.backup_file_name }}