Symptoms
- Job runs fail at the first task with
Notebook not found,RESOURCE_DOES_NOT_EXISTor a missing workspace file path. - Jobs are missing from the Jobs list. Their schedules didn't fire, so downstream tables are stale and nothing alerted.
- A user folder or a shared folder like
/Workspace/Shared/prodis empty or gone. - Started after someone left the company (user folder cleanup), a "tidy up old notebooks" script, or a CLI command with a wrong path.
Notebooks and jobs are recovered differently. Work out which you lost first.
Warning
Notebooks deleted in the UI go to Trash for 30 days, and Empty Trash removes them for good. Objects deleted with the CLI or Workspace API do not go to Trash. Deleted jobs can't be undeleted. Tell everyone involved to stop cleaning up until recovery is done.
1. Confirm scope and impact (10 minutes)
Find what was deleted, by whom, and how. In a notebook or SQL warehouse with system tables enabled:
SELECT event_time, user_identity.email, service_name, action_name,
request_params, user_agent
FROM system.access.audit
WHERE workspace_id = '<workspace-id>'
AND event_time > now() - INTERVAL 7 DAYS
AND service_name IN ('notebook', 'workspace', 'jobs', 'repos')
AND action_name ILIKE '%delete%'
ORDER BY event_time DESC;
user_agenttells you whether the delete came from the browser, the CLI, Terraform or an SDK. A browser delete means Trash has a chance. A CLI or API delete means it does not.request_paramsholds the path (notebooks) orjob_id(jobs).
List the jobs that failed or should have run:
databricks jobs list-runs --completed-only --limit 200 -p prod -o json \
| jq -r '.[] | select(.state.result_state=="FAILED") | [.job_id, .run_name, .state.state_message] | @tsv'
| Lost | Recovery path |
|---|---|
| Notebooks deleted in UI, Trash not emptied | Step 2 (Trash) |
| Notebooks deleted by CLI/API, or Trash emptied | Step 3 (Git or exports) |
| Job definitions | Step 4 (bundles, Terraform or audit data) |
| Whole user folder of a removed user | Step 2. Admins can see other users' Trash and folders. |
2. Restore notebooks from Trash
Trash restores are done in the UI:
- Open Workspace, then the Trash of the user who deleted the items. Workspace admins can open any user's Trash.
- Select the notebooks or folder and move them back to the original path. Jobs reference notebooks by path, so a different path still breaks them.
- Notebook revision history comes back with the notebook.
Check the restored path matches what the job expects:
databricks workspace get-status "/Workspace/Shared/prod/etl/load_orders" -p prod
databricks jobs get <job-id> -p prod -o json | jq '.settings.tasks[] | {task_key, notebook: .notebook_task.notebook_path}'
3. Restore notebooks from Git or exports
If production jobs run from a Git source (recommended), the notebooks were never only in the workspace:
- Jobs with a Git source (
git_sourcein the job settings) fetch code at run time. Deleting a workspace copy doesn't affect them. - Git folders: recreate the Git folder at the same path and check out the production branch:
databricks repos create https://dev.azure.com/org/project/_git/etl azureDevOpsServices \
--path /Workspace/Repos/prod/etl -p prod
databricks repos update <repo-id> --branch main -p prod
- Notebooks only in the workspace: look for a recent export (
databricks workspace export-dirbackups) or a copy in another workspace, and import it to the original path:
databricks workspace import-dir ./backup/prod/etl /Workspace/Shared/prod/etl -p prod
If none of those exist, check whether a colleague has the code open in another tab, a local IDE sync, or a dev workspace. Then rewrite the code from the latest job run output. A failed run's task page shows the notebook as it was at that run.
4. Rebuild deleted jobs
Job IDs can't be recovered. A rebuilt job gets a new job ID. Anything that calls it by ID (Data Factory activities, external schedulers, run_job_task, scripts) needs updating.
If the job is in an Asset Bundle or Terraform, redeploy. This is the fast path:
databricks bundle deploy -t prod
databricks bundle summary -t prod # shows the new job IDs
terraform plan # shows the deleted jobs as resources to create
terraform apply
If the job existed only in the UI, rebuild it from what's left:
- Look in the audit log for the job's
createandreset/updateevents.request_paramsusually contains the settings that were submitted:
SELECT event_time, action_name, request_params
FROM system.access.audit
WHERE service_name = 'jobs'
AND action_name IN ('create', 'reset', 'update')
AND to_json(request_params) ILIKE '%load_orders%'
ORDER BY event_time DESC;
- Use the Lakeflow system tables for structure (name, tasks, dependencies), where enabled. Column names vary by release, so check the schema first:
SELECT * FROM system.lakeflow.jobs WHERE name ILIKE '%orders%' ORDER BY change_time DESC LIMIT 5;
SELECT * FROM system.lakeflow.job_tasks WHERE job_id = '<old-job-id>' ORDER BY change_time DESC;
- Recreate the job from JSON and keep the file. It becomes the start of your bundle:
databricks jobs create --json @load_orders_job.json -p prod
5. Verify recovery
- Each restored job's tasks point at existing notebooks or a Git source. Run each one once with Run now, or with the date parameters of the missed runs.
- Schedules, retries, notifications, run-as identity and permissions are set again. Permissions are not restored with a rebuilt job:
databricks permissions get jobs <new-job-id> -p prod
- External callers (ADF linked services, schedulers) use the new job IDs.
- Downstream tables are back to date. Backfill the missed days in order.
Communicate
"From [date/time] [N] production jobs did not run because their [notebooks / job definitions] were deleted during [cleanup / offboarding]. Code was restored from [Trash / Git] and jobs were rebuilt. Missed runs for [dates] are being backfilled, ETA HH:MM. [Tables] will be current after that."
Prevent it next time
- Run production jobs from Git (
git_source) or Asset Bundles, never from personal folders or hand-edited workspace notebooks. - Manage all production jobs as code (bundles or Terraform). A deleted job becomes a single
deploy. - Run production jobs as a service principal and keep code out of user folders, so offboarding a person doesn't touch production.
- Restrict
CAN_MANAGEon production folders and jobs to the platform group. Give everyone elseCAN_RUNorCAN_VIEW. - Schedule a nightly
databricks workspace export-dirof shared production folders to storage as a backstop. - Alert on
deleteevents from thejobs,notebookandworkspaceservices insystem.access.auditfor production paths.
Get the weekly HubDatAI email
One email a week with everything new: posts, learning sessions and videos. Free, no spam, unsubscribe in one click. What you get