File tree Expand file tree Collapse file tree 12 files changed +74
-5
lines changed
charts/postgres-operator/crds Expand file tree Collapse file tree 12 files changed +74
-5
lines changed Original file line number Diff line number Diff line change @@ -498,6 +498,12 @@ spec:
498
498
type : string
499
499
pattern : ' ^(\d+|\*)(/\d+)?(\s+(\d+|\*)(/\d+)?){4}$'
500
500
default : " 30 00 * * *"
501
+ logical_backup_azure_storage_account_name :
502
+ type : string
503
+ logical_backup_azure_storage_container :
504
+ type : string
505
+ logical_backup_azure_storage_account_key :
506
+ type : string
501
507
debug :
502
508
type : object
503
509
properties :
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ RUN apt-get update \
15
15
gnupg \
16
16
gcc \
17
17
libffi-dev \
18
+ && curl -sL https://aka.ms/InstallAzureCLIDeb | bash \
18
19
&& pip3 install --upgrade pip \
19
20
&& pip3 install --no-cache-dir awscli --upgrade \
20
21
&& pip3 install --no-cache-dir gsutil --upgrade \
Original file line number Diff line number Diff line change @@ -40,6 +40,12 @@ function compress {
40
40
pigz
41
41
}
42
42
43
+ function az_upload {
44
+ PATH_TO_BACKUP=$LOGICAL_BACKUP_S3_BUCKET " /spilo/" $SCOPE$LOGICAL_BACKUP_S3_BUCKET_SCOPE_SUFFIX " /logical_backups/" $( date +%s) .sql.gz
45
+
46
+ az storage blob upload --file " $1 " --account-name " $LOGICAL_BACKUP_AZURE_STORAGE_ACCOUNT_NAME " --account-key " $LOGICAL_BACKUP_AZURE_STORAGE_ACCOUNT_KEY " -c " $LOGICAL_BACKUP_AZURE_STORAGE_CONTAINER " -n " $PATH_TO_BACKUP "
47
+ }
48
+
43
49
function aws_delete_objects {
44
50
args=(
45
51
" --bucket=$LOGICAL_BACKUP_S3_BUCKET "
@@ -120,7 +126,7 @@ function upload {
120
126
" gcs" )
121
127
gcs_upload
122
128
;;
123
- * )
129
+ " aws " )
124
130
aws_upload $(( $(estimate_size) / DUMP_SIZE_COEFF))
125
131
aws_delete_outdated
126
132
;;
@@ -174,8 +180,13 @@ for search in "${search_strategy[@]}"; do
174
180
done
175
181
176
182
set -x
177
- dump | compress | upload
178
- [[ ${PIPESTATUS[0]} != 0 || ${PIPESTATUS[1]} != 0 || ${PIPESTATUS[2]} != 0 ]] && (( ERRORCOUNT += 1 ))
179
- set +x
183
+ if [ " $LOGICAL_BACKUP_PROVIDER " == " az" ]; then
184
+ dump | compress > /tmp/azure-backup.sql.gz
185
+ az_upload /tmp/azure-backup.sql.gz
186
+ else
187
+ dump | compress | upload
188
+ [[ ${PIPESTATUS[0]} != 0 || ${PIPESTATUS[1]} != 0 || ${PIPESTATUS[2]} != 0 ]] && (( ERRORCOUNT += 1 ))
189
+ set +x
180
190
181
- exit $ERRORCOUNT
191
+ exit $ERRORCOUNT
192
+ fi
Original file line number Diff line number Diff line change @@ -765,6 +765,15 @@ grouped under the `logical_backup` key.
765
765
[ reference schedule format] ( https://kubernetes.io/docs/tasks/job/automated-tasks-with-cron-jobs/#schedule )
766
766
into account. Default: "30 00 \* \* \* "
767
767
768
+ * ** logical_backup_azure_storage_account_name**
769
+ Storage account name used to upload logical backups to when using Azure. Default: ""
770
+
771
+ * ** logical_backup_azure_storage_container**
772
+ Storage container used to upload logical backups to when using Azure. Default: ""
773
+
774
+ * ** logical_backup_azure_storage_account_key**
775
+ Storage account key used to authenticate with Azure when uploading logical backups. Default: ""
776
+
768
777
## Debugging the operator
769
778
770
779
Options to aid debugging of the operator itself. Grouped under the ` debug ` key.
Original file line number Diff line number Diff line change 87
87
logical_backup_s3_sse : " AES256"
88
88
# logical_backup_s3_retention_time: ""
89
89
logical_backup_schedule : " 30 00 * * *"
90
+ # logical_backup_azure_storage_account_name: ""
91
+ # logical_backup_azure_storage_container: ""
92
+ # logical_backup_azure_storage_account_key: ""
90
93
major_version_upgrade_mode : " manual"
91
94
# major_version_upgrade_team_allow_list: ""
92
95
master_dns_name_format : " {cluster}.{namespace}.{hostedzone}"
Original file line number Diff line number Diff line change @@ -496,6 +496,12 @@ spec:
496
496
type : string
497
497
pattern : ' ^(\d+|\*)(/\d+)?(\s+(\d+|\*)(/\d+)?){4}$'
498
498
default : " 30 00 * * *"
499
+ logical_backup_azure_storage_account_name :
500
+ type : string
501
+ logical_backup_azure_storage_container :
502
+ type : string
503
+ logical_backup_azure_storage_account_key :
504
+ type : string
499
505
debug :
500
506
type : object
501
507
properties :
Original file line number Diff line number Diff line change @@ -163,6 +163,9 @@ configuration:
163
163
logical_backup_s3_sse : " AES256"
164
164
# logical_backup_s3_retention_time: ""
165
165
logical_backup_schedule : " 30 00 * * *"
166
+ # logical_backup_azure_storage_account_name: ""
167
+ # logical_backup_azure_storage_container: ""
168
+ # logical_backup_azure_storage_account_key: ""
166
169
debug :
167
170
debug_logging : true
168
171
enable_database_access : true
Original file line number Diff line number Diff line change @@ -1655,6 +1655,15 @@ var OperatorConfigCRDResourceValidation = apiextv1.CustomResourceValidation{
1655
1655
Type : "string" ,
1656
1656
Pattern : "^(\\ d+|\\ *)(/\\ d+)?(\\ s+(\\ d+|\\ *)(/\\ d+)?){4}$" ,
1657
1657
},
1658
+ "logical_backup_azure_storage_account_name" : {
1659
+ Type : "string" ,
1660
+ },
1661
+ "logical_backup_azure_storage_container" : {
1662
+ Type : "string" ,
1663
+ },
1664
+ "logical_backup_azure_storage_account_key" : {
1665
+ Type : "string" ,
1666
+ },
1658
1667
},
1659
1668
},
1660
1669
"debug" : {
Original file line number Diff line number Diff line change @@ -227,6 +227,9 @@ type OperatorLogicalBackupConfiguration struct {
227
227
RetentionTime string `json:"logical_backup_s3_retention_time,omitempty"`
228
228
GoogleApplicationCredentials string `json:"logical_backup_google_application_credentials,omitempty"`
229
229
JobPrefix string `json:"logical_backup_job_prefix,omitempty"`
230
+ AzureStorageAccountName string `json:"logical_backup_azure_storage_account_name,omitempty"`
231
+ AzureStorageContainer string `json:"logical_backup_azure_storage_container,omitempty"`
232
+ AzureStorageAccountKey string `json:"logical_backup_azure_storage_account_key,omitempty"`
230
233
}
231
234
232
235
// PatroniConfiguration defines configuration for Patroni
Original file line number Diff line number Diff line change @@ -2262,6 +2262,18 @@ func (c *Cluster) generateLogicalBackupPodEnvVars() []v1.EnvVar {
2262
2262
Name : "LOGICAL_BACKUP_GOOGLE_APPLICATION_CREDENTIALS" ,
2263
2263
Value : c .OpConfig .LogicalBackup .LogicalBackupGoogleApplicationCredentials ,
2264
2264
},
2265
+ {
2266
+ Name : "LOGICAL_BACKUP_AZURE_STORAGE_ACCOUNT_NAME" ,
2267
+ Value : c .OpConfig .LogicalBackup .LogicalBackupAzureStorageAccountName ,
2268
+ },
2269
+ {
2270
+ Name : "LOGICAL_BACKUP_AZURE_STORAGE_CONTAINER" ,
2271
+ Value : c .OpConfig .LogicalBackup .LogicalBackupAzureStorageContainer ,
2272
+ },
2273
+ {
2274
+ Name : "LOGICAL_BACKUP_AZURE_STORAGE_ACCOUNT_KEY" ,
2275
+ Value : c .OpConfig .LogicalBackup .LogicalBackupAzureStorageAccountKey ,
2276
+ },
2265
2277
// Postgres env vars
2266
2278
{
2267
2279
Name : "PG_VERSION" ,
You can’t perform that action at this time.
0 commit comments