Skip to content

Commit

Permalink
chore: Refactor extract-content.py to include skip flags for re-runni…
Browse files Browse the repository at this point in the history
…ng migration
  • Loading branch information
georearl committed May 9, 2024
1 parent 41b338d commit 2d5a89a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
11 changes: 10 additions & 1 deletion docs/deployment/migrate.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,13 @@ make merge-databases
```bash
make run-data-migration
```
Once complete, your new deployment of 1.1 should be functional and contain the processed content from your 1.0 deployment. You can now plan to retire you old 1.0 deployment.
Once complete, your new deployment of 1.1 should be functional and contain the processed content from your 1.0 deployment. You can now plan to retire you old 1.0 deployment.

## Re-running a migration
If you encounter a failure while running the migration, you can re-run the process, but you have the option to skip steps to avoid repetition. You have the option of setting these values to True in the file called extract-content.py in the scripts folder:
```bash
skip_search_index = False
skip_cosmos_db = False
skip_upload_container = False
skip_content_container = False
```
9 changes: 9 additions & 0 deletions scripts/extract-content.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from pyfiglet import Figlet
import json
import subprocess
import sys
import os
from azure.cosmos import CosmosClient, PartitionKey, exceptions
from azure.identity import DefaultAzureCredential
Expand Down Expand Up @@ -181,6 +182,10 @@ def get_storage_account_endpoint(storage_account_name):
old_search_client = SearchClient(endpoint=old_search_endpoint, index_name=index_name, credential=AzureKeyCredential(old_search_key))
new_search_client = SearchClient(endpoint=new_search_endpoint, index_name=index_name, credential=AzureKeyCredential(new_search_key))

error_guidance = 'If you re-run the process, you can skip sections that completed successfully by setting the corresponding skip flag to True. Read more details her'





# *************************************************************************
Expand Down Expand Up @@ -240,6 +245,7 @@ def get_storage_account_endpoint(storage_account_name):

except Exception as e:
print(e)
sys.exit()



Expand Down Expand Up @@ -320,6 +326,7 @@ def get_storage_account_endpoint(storage_account_name):

except exceptions.CosmosHttpResponseError as e:
print(f'An error occurred: {e}')
sys.exit()


# *************************************************************************
Expand Down Expand Up @@ -376,6 +383,7 @@ def get_storage_account_endpoint(storage_account_name):

except Exception as e:
print(e)
sys.exit()

print(f"Completed migratiing upload container blobs. Processed {blobs_processed_count} blobs")

Expand Down Expand Up @@ -417,6 +425,7 @@ def get_storage_account_endpoint(storage_account_name):

except Exception as e:
print(e)
sys.exit()

print(f"Completed migratiing content container chnks. Processed {chunks_processed_count} blobs")

Expand Down

0 comments on commit 2d5a89a

Please sign in to comment.