File tree Expand file tree Collapse file tree 3 files changed +11
-6
lines changed
Expand file tree Collapse file tree 3 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,8 @@ AIRFLOW_VAR_MATRIX_WEBHOOK_API_KEY=api_key
4545
4646S3_LOCAL_ENDPOINT = http://s3:5000
4747SPACES_CONN_ID = aws_default
48+ # Optional bucket to use, necessary prefix in all cases for DigitalOcean Spaces
49+ # SPACES_BUCKET_NAME=bucketname
4850
4951# #######################################################################################
5052# Other config
Original file line number Diff line number Diff line change 33
44SSH_MONOLITH_CONN_ID = "ssh_monolith"
55SPACES_CONN_ID = os .getenv ("SPACES_CONN_ID" )
6+ SPACES_BUCKET_NAME = os .getenv ("SPACES_BUCKET_NAME" , "" )
7+ # DigitalOcean Spaces has a common shared bucket for everything, whereas locally we
8+ # have a separate bucket for each service. If the bucket name is defined, all keys
9+ # will be prefixed with that.
10+ SPACES_KEY_PREFIX = f"s3://{ SPACES_BUCKET_NAME } /" if SPACES_BUCKET_NAME else "s3://"
611
712MATRIX_WEBHOOK_CONN_ID = "matrix_webhook"
813MATRIX_WEBHOOK_API_KEY = "matrix_webhook_api_key"
Original file line number Diff line number Diff line change 1313
1414
1515LOCAL_BACKUPS_FOLDER = "/opt/backups"
16- BUCKET_NAME = "monolith-backups"
16+ KEY_BASE = constants . SPACES_KEY_PREFIX + "monolith-backups"
1717
1818
1919@task_group
2020def backup_service (config : OffsiteConfig ):
2121 local_backup = f"{ LOCAL_BACKUPS_FOLDER } /{ config .filename } "
22+ s3_key = f"{ KEY_BASE } /{ config .filename } "
2223
2324 backup = SSHOperator (
2425 task_id = f"backup_{ config .name } " ,
@@ -35,17 +36,14 @@ def backup_service(config: OffsiteConfig):
3536 copy_to_spaces = LocalFilesystemToS3Operator (
3637 task_id = f"copy_local_{ config .name } _to_spaces" ,
3738 aws_conn_id = constants .SPACES_CONN_ID ,
38- dest_bucket = BUCKET_NAME ,
39- dest_key = config .filename ,
39+ dest_key = s3_key ,
4040 replace = True ,
4141 filename = local_backup ,
4242 )
4343
4444 @task (retries = 3 , retry_exponential_backoff = True )
4545 def notify_backup_complete ():
46- matrix .send_message (
47- f"{ config .name } backup complete at: `s3://{ BUCKET_NAME } /{ config .filename } `"
48- )
46+ matrix .send_message (f"{ config .name } backup complete at: `{ s3_key } `" )
4947
5048 restart_if_failed = SSHOperator (
5149 task_id = f"start_if_failed_{ config .name } " ,
You can’t perform that action at this time.
0 commit comments