Databricks

Databricks Workspace Export / Import: Practical Guide

2026-03-26
更新: 2026-03-27
NicheeLab Editorial Team

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.

Export Format Comparison

When you export a notebook from a Databricks workspace, you can choose between several formats.

FormatExtensionWhat's includedUse caseImportable?
DBC.dbcNotebook body, metadata, cell structure, folder structureBackups, workspace-to-workspace migrationYes (full restore)
SOURCE.py / .sql / .scala / .rSource code only (cell boundaries marked as comments)Git management, CI/CD, code reviewYes (imported as a notebook)
HTML.htmlRendered notebook (code + outputs + charts)Documentation sharing, report distributionNo (read-only)
JUPYTER.ipynbJupyter-format notebook (cells, metadata, outputs)Migration to Jupyter Notebook-compatible environmentsYes

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.

Export / Import via Databricks CLI

Using the Databricks CLI, you can run Export / Import as a batch operation from the command line.

Exporting a single notebook

# 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

Batch-exporting an entire folder

# フォルダ全体をSOURCE形式で一括エクスポート
databricks workspace export_dir \
  /Workspace/Shared/etl-project \
  ./backup/etl-project \
  --overwrite

Import

# 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 \
  --overwrite

Export / Import via REST API

When 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.

What's Included and Excluded in Exports

ItemDBCSOURCEHTML
Source codeIncludedIncludedIncluded (as HTML)
Cell structure / metadataIncludedExpressed via commentsAlready rendered
Execution results / outputsNot includedNot includedIncluded
DashboardsIncluded (if attached to the notebook)Not includedIncluded
Workspace permissions (ACLs)Not includedNot includedNot included
Secret Scope contentsNot includedNot includedNot included
Cluster configurationNot includedNot includedNot included
Job definitionsNot includedNot includedNot 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.

Integration with Terraform

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.

Workspace Migration Patterns

There are several approaches for migrating notebooks between workspaces.

PatternMethodWhen to use
Manual Export/ImportExport as DBC from the UI → import in the other workspaceMigrating a small number of notebooks (up to a few dozen)
CLI batch processingexport_dir import_dirMigrating large numbers of notebooks (hundreds or more)
Via GitPush from the source workspace via Repos → clone in the destination workspaceProjects already under Git management
TerraformChange the target in your IaC code and apply against another workspaceWhole-environment migrations that include infrastructure

Best Practices

  • Use CLI export_dir + DBC for regular backups: back up workspace notebooks in DBC format on a regular schedule via a cron job or CI/CD schedule.
  • Remove hardcoded secrets before migrating: migrate to the Secret Scope approach beforehand so that no secrets end up in the exported code.
  • Migrate permissions separately: notebook Export/Import does not carry over permissions, so re-apply them using the Permissions API or Terraform.
  • Move to Repos + DABs for the long term: Export/Import is useful for one-off migrations and backups, but Repos + DABs is the better fit for continuous deployment.

Key Points for the Exam

  • "How do I migrate notebooks between workspaces?" → Export/Import (DBC format) or Git Clone via Repos
  • "Are permissions included in exports?" → No (you must configure them separately via the Permissions API)
  • "What's the difference between SOURCE and DBC?" → SOURCE is source code only; DBC is an archive that includes metadata
  • "Can HTML exports be imported?" → No (it's a read-only report format)

Test Yourself

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?

  1. Export the entire folder in DBC format, import it into the production workspace, then configure permissions via the Permissions API
  2. Export the notebooks in SOURCE format and import them into the production workspace
  3. Export the notebooks in HTML format and import them into the production workspace
  4. Copy the notebook files from the development DBFS and place them in the production DBFS

正解: 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.

Frequently Asked Questions

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.

Check what you learned with practice questions

Practice with certification-focused question sets

無料で問題を解いてみる
Author

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.


Related articles
Databricks

Databricks Certifications: All 7 Exams, Difficulty & Study Plan (2026)

Complete guide to all 7 Databricks certifications — Data Eng...

Databricks

Databricks Exam Difficulty Ranking: All 7 Certs Compared (2026)

Every Databricks certification ranked by difficulty, with st...

Databricks

Databricks Study Guide: Fastest Pass Route & Time Estimates (2026)

How to pass Databricks certifications efficiently. Official ...

Databricks

Databricks Data Engineer Associate: Complete Guide (2026)

Domain-by-domain breakdown of the Databricks Certified Data ...

Databricks

Databricks Data Engineer Professional: Complete Guide (2026)

Tactics for the Databricks Certified Data Engineer Professio...

Browse all Databricks articles (110)
© 2026 NicheeLab All rights reserved.