-
Notifications
You must be signed in to change notification settings - Fork 17.3k
Add incremental export and cross account export functionality in DynamoDBToS3Operator
#41304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 8 commits
6645c6a
9d3f188
3ff5ba5
dc9b48a
9fa988a
56b5c46
35d40a9
078b7d8
b05690c
493f507
76b5522
27436c4
7dc0b6a
6b7ce52
cd8fca0
1082149
33c203a
9d74345
0cea15d
aa8326b
747be27
d04d1b8
e269e65
f7b5e0f
0a195aa
197fb43
f3a0083
44cdeac
38a3b00
c4085ba
a111edc
0ed60a5
d950db2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -92,6 +92,15 @@ def get_export_time(table_name: str): | |
| return r["ContinuousBackupsDescription"]["PointInTimeRecoveryDescription"]["EarliestRestorableDateTime"] | ||
|
|
||
|
|
||
| @task | ||
| def get_latest_export_time(table_name: str): | ||
| r = boto3.client("dynamodb").describe_continuous_backups( | ||
| TableName=table_name, | ||
| ) | ||
|
|
||
| return r["ContinuousBackupsDescription"]["PointInTimeRecoveryDescription"]["LatestRestorableDateTime"] | ||
|
|
||
|
|
||
| @task | ||
| def wait_for_bucket(s3_bucket_name): | ||
| waiter = boto3.client("s3").get_waiter("bucket_exists") | ||
|
|
@@ -162,18 +171,36 @@ def delete_dynamodb_table(table_name: str): | |
| # [END howto_transfer_dynamodb_to_s3_segmented] | ||
|
|
||
| export_time = get_export_time(table_name) | ||
| # [START howto_transfer_dynamodb_to_s3_in_some_point_in_time] | ||
| backup_db_to_point_in_time = DynamoDBToS3Operator( | ||
| task_id="backup_db_to_point_in_time", | ||
| latest_export_time = get_latest_export_time(table_name) | ||
| # [START howto_transfer_dynamodb_to_s3_in_some_point_in_time (Full Export)] | ||
| backup_db_to_point_in_time_full_export = DynamoDBToS3Operator( | ||
| task_id="backup_db_to_point_in_time_full_export", | ||
| dynamodb_table_name=table_name, | ||
| file_size=1000, | ||
| s3_bucket_name=bucket_name, | ||
| point_in_time_export=True, | ||
| export_time=export_time, | ||
| s3_key_prefix=f"{S3_KEY_PREFIX}-3-", | ||
| ) | ||
| # [END howto_transfer_dynamodb_to_s3_in_some_point_in_time] | ||
| # [END howto_transfer_dynamodb_to_s3_in_some_point_in_time (Full Export)] | ||
|
|
||
| # [START howto_transfer_dynamodb_to_s3_in_some_point_in_time (Incremental Export)] | ||
| backup_db_to_point_in_time_incremental_export = DynamoDBToS3Operator( | ||
| task_id="backup_db_to_point_in_time_full_export", | ||
| dynamodb_table_name=table_name, | ||
| file_size=1000, | ||
| s3_bucket_name=bucket_name, | ||
| point_in_time_export=True, | ||
| s3_key_prefix=f"{S3_KEY_PREFIX}-4-", | ||
| export_type="INCREMENTAL_EXPORT", | ||
| incremental_export_from_time=export_time, | ||
| incremental_export_to_time=latest_export_time, | ||
| incremental_export_view_type="NEW_AND_OLD_IMAGES", | ||
| ) | ||
| # [END howto_transfer_dynamodb_to_s3_in_some_point_in_time (Incremental Export)] | ||
| # This operation can take a long time to complete | ||
| backup_db_to_point_in_time.max_attempts = 90 | ||
| backup_db_to_point_in_time_full_export.max_attempts = 90 | ||
| backup_db_to_point_in_time_incremental_export.max_attempts = 90 | ||
|
|
||
| delete_table = delete_dynamodb_table(table_name=table_name) | ||
|
|
||
|
|
@@ -195,7 +222,8 @@ def delete_dynamodb_table(table_name: str): | |
| backup_db_segment_1, | ||
| backup_db_segment_2, | ||
| export_time, | ||
| backup_db_to_point_in_time, | ||
| backup_db_to_point_in_time_full_export, | ||
|
Comment on lines
227
to
+228
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Insert Without it listed in the chain(), it fires off at the very beginning and causes the test to fail because env_id isn't populated yet.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed in #41517 |
||
| backup_db_to_point_in_time_incremental_export, | ||
| # TEST TEARDOWN | ||
| delete_table, | ||
| delete_bucket, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.