When you need to migrate notebooks, folders, and files between Databricks workspaces, take backups, or hand code off to a CI/CD pipeline, the tool you reach for is Workspace Export / Import.
This article walks through the differences between export formats (DBC/SOURCE/HTML), the commands used via Databricks CLI and REST API, how Terraform integration works, and how permissions and secrets are handled during export.
When you export a notebook from a Databricks workspace, you can choose between several formats.
| Format | Extension | What's included | Use case | Importable? |
|---|---|---|---|---|
| DBC | .dbc | Notebook body, metadata, cell structure, folder structure | Backups, workspace-to-workspace migration | Yes (full restore) |
| SOURCE | .py / .sql / .scala / .r | Source code only (cell boundaries marked as comments) | Git management, CI/CD, code review | Yes (imported as a notebook) |
| HTML | .html | Rendered notebook (code + outputs + charts) | Documentation sharing, report distribution | No (read-only) |
| JUPYTER | .ipynb | Jupyter-format notebook (cells, metadata, outputs) | Migration to Jupyter Notebook-compatible environments | Yes |
DBC is a Databricks-specific archive (actually a ZIP file under the hood) that lets you export an entire folder in one shot. SOURCE produces plain source code files, which is ideal for storing in a Git repository and reviewing in PRs.
Using the Databricks CLI, you can run Export / Import as a batch operation from the command line.
# SOURCE形式でエクスポート
databricks workspace export \
/Workspace/Users/[email protected]/etl_pipeline \
--file ./etl_pipeline.py \
--format SOURCE
# DBC形式でエクスポート
databricks workspace export \
/Workspace/Users/[email protected]/etl_pipeline \
--file ./etl_pipeline.dbc \
--format DBC
# HTML形式でエクスポート(レポート共有用)
databricks workspace export \
/Workspace/Users/[email protected]/etl_pipeline \
--file ./etl_pipeline.html \
--format HTML# フォルダ全体をSOURCE形式で一括エクスポート
databricks workspace export_dir \
/Workspace/Shared/etl-project \
./backup/etl-project \
--overwrite# SOURCE形式のインポート
databricks workspace import \
--path /Workspace/Users/[email protected]/etl_pipeline \
--file ./etl_pipeline.py \
--format SOURCE \
--language PYTHON
# DBC形式の一括インポート
databricks workspace import_dir \
./backup/etl-project \
/Workspace/Shared/etl-project-restored \
--overwriteWhen you need to run Export / Import programmatically from a CI/CD pipeline, the REST API is the right tool.
# エクスポート(SOURCE形式)
curl -X GET \
"https://<workspace-url>/api/2.0/workspace/export" \
-H "Authorization: Bearer <token>" \
-d '{
"path": "/Workspace/Users/[email protected]/etl_pipeline",
"format": "SOURCE"
}'
# レスポンス(Base64エンコードされたコンテンツ)
{
"content": "IyBEYXRhYnJpY2tzIG5vdGVib29rIHNvdXJjZQ...",
"file_type": "py"
}# インポート(SOURCE形式)
curl -X POST \
"https://<workspace-url>/api/2.0/workspace/import" \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"path": "/Workspace/Users/[email protected]/etl_pipeline_v2",
"format": "SOURCE",
"language": "PYTHON",
"content": "IyBEYXRhYnJpY2tzIG5vdGVib29rIHNvdXJjZQ...",
"overwrite": true
}'Note that the REST API content is Base64-encoded. When migrating large numbers of notebooks, the CLI's export_dir/import_dir commands are more efficient.
| Item | DBC | SOURCE | HTML |
|---|---|---|---|
| Source code | Included | Included | Included (as HTML) |
| Cell structure / metadata | Included | Expressed via comments | Already rendered |
| Execution results / outputs | Not included | Not included | Included |
| Dashboards | Included (if attached to the notebook) | Not included | Included |
| Workspace permissions (ACLs) | Not included | Not included | Not included |
| Secret Scope contents | Not included | Not included | Not included |
| Cluster configuration | Not included | Not included | Not included |
| Job definitions | Not included | Not included | Not included |
Workspace permissions (ACLs), Secret Scopes, cluster configurations, and job definitions are not exported in any format. To migrate these resources, you need to use the Databricks Terraform Provider or the per-resource APIs in the Databricks CLI individually.
To manage notebook placement in the workspace as IaC, use the Terraform Provider's databricks_notebook resource.
resource "databricks_notebook" "etl_pipeline" {
path = "/Workspace/Shared/etl-project/etl_pipeline"
language = "PYTHON"
source = "${path.module}/notebooks/etl_pipeline.py"
}
resource "databricks_notebook" "data_quality" {
path = "/Workspace/Shared/etl-project/data_quality"
language = "SQL"
source = "${path.module}/notebooks/data_quality.sql"
}The benefit of managing this with Terraform is unified management of not just notebook placement, but also clusters, jobs, permissions, Secret Scopes, and other resources. That said, the Terraform apply cycle is heavy for frequent notebook updates. A realistic split is: Repos during the development phase, and DABs or Terraform during the deployment phase.
There are several approaches for migrating notebooks between workspaces.
| Pattern | Method | When to use |
|---|---|---|
| Manual Export/Import | Export as DBC from the UI → import in the other workspace | Migrating a small number of notebooks (up to a few dozen) |
| CLI batch processing | export_dir → import_dir | Migrating large numbers of notebooks (hundreds or more) |
| Via Git | Push from the source workspace via Repos → clone in the destination workspace | Projects already under Git management |
| Terraform | Change the target in your IaC code and apply against another workspace | Whole-environment migrations that include infrastructure |
Development Tools
問題 1
You need to migrate notebooks from a development Databricks workspace to a production workspace. You want to fully preserve the notebook code, cell structure, and folder structure. Permissions, however, differ between the two environments and will be configured separately. Which migration approach is most appropriate?
正解: A
DBC is an archive format that fully preserves cell structure, metadata, and folder structure. Permissions are not included in exports, so you set them via the Permissions API after import. SOURCE contains only source code and doesn't guarantee full preservation of cell structure. HTML is read-only and cannot be imported. Notebooks are stored in the workspace file tree, not in DBFS, so copying DBFS files does not migrate notebooks.
Should I export in DBC or SOURCE format?
It depends on the use case. DBC is a Databricks-specific archive format that fully preserves notebook metadata, cell structure, and dashboards. It's ideal for workspace-to-workspace migrations and backups. SOURCE exports pure source code (.py/.sql/.scala/.r), making it ideal for Git management and CI/CD pipelines. HTML is a read-only format for sharing documentation. In general: use DBC for backups, SOURCE for development, and HTML for report sharing.
Are secrets included in the exported content?
No. Secrets retrieved via dbutils.secrets.get() are stored securely inside the Secret Scope and are not included in notebook exports. However, the scope name and key name are written in the code, so anyone reading the exported code can infer which secrets are referenced. Also, any secrets hardcoded inside the notebook (a bad practice but it happens) will be included in SOURCE and DBC exports. It's critical to remove hardcoded secrets from your code before exporting.
How is Workspace Export / Import tested on the certification exams?
It appears in the 'Development Tools' domain of the Data Engineer Associate exam and the 'Deployment and Management' domain of the Professional exam. Typical question patterns include: how to migrate notebooks between workspaces, CLI commands for batch export, the difference between DBC and SOURCE formats, and what is or isn't included in exports. Questions about Terraform integration and when to choose DABs may also appear.
Practice with certification-focused question sets
無料で問題を解いてみるNicheeLab Editorial Team
NicheeLab editorial team focused on data engineering and cloud certification learning. Content is structured around practical study needs and official exam domains.
Databricks Certifications: All 7 Exams, Difficulty & Study Plan (2026)
Complete guide to all 7 Databricks certifications — Data Eng...
Databricks Exam Difficulty Ranking: All 7 Certs Compared (2026)
Every Databricks certification ranked by difficulty, with st...
Databricks Study Guide: Fastest Pass Route & Time Estimates (2026)
How to pass Databricks certifications efficiently. Official ...
Databricks Data Engineer Associate: Complete Guide (2026)
Domain-by-domain breakdown of the Databricks Certified Data ...
Databricks Data Engineer Professional: Complete Guide (2026)
Tactics for the Databricks Certified Data Engineer Professio...