%pip install semantic-link-labs
import sempy_labs as labs
source_dataset = '' # Name of the semantic model to backup
target_dataset = '' # Name of the semantic model to restore
source_workspace = '' # Name of the workspace in which the semantic model resides
target_workspace = '' # Destination workspace of the semantic model
source_file_path = '' # Name/path of the backup file to create
target_file_path = '' # Name/path of the backup file to be copied to the target workspace
storage_account = '' # Name of the ADLS Gen2 storage account associated with both source & target workspaces
labs.backup_semantic_model(
dataset=source_dataset,
file_path=source_file_path,
workspace=source_workspace,
)
labs.copy_semantic_model_backup_file(
source_workspace=source_workspace,
target_workspace=target_workspace,
source_file_name=source_file_path,
target_file_name=target_file_path,
storage_account=storage_account,
)
labs.restore_semantic_model(
dataset=target_dataset,
file_path=target_file_path,
workspace=target_workspace,
)