You can get a DACPAC back by extracting it fresh from the live database, pulling the original from source control or the build artifact that produced it, restoring it from a backup, or, only when none of those exist, unpacking it out of the deployment records SQL Server left behind. The right route depends on one question: was the file ever generated from a database you still control? If yes, regeneration takes minutes and is the safest option. If the database is gone too, recovery gets harder and sometimes impossible, so work through the options below in order rather than reaching for file-undelete tools first.
What a DACPAC actually is, and why that changes your recovery options
A DACPAC is a ZIP archive with a .dacpac extension. Inside sit XML files describing your schema — tables, views, procedures, users, permissions — plus a model.xml that SqlPackage or SSDT reads. If you rename a copy to .zip, Windows Explorer opens it, which is the single most useful fact for anyone trying to salvage one.
That structure matters because the file is generated, not authored. A DACPAC is produced from a database or an SSDT project, so as long as either still exists, you can rebuild a byte-for-byte-equivalent schema definition. The catch is data: a DACPAC never contains table rows, only the schema and (when exported with the right flag) server-level or database-level security objects. Getting the file back restores your deployment capability, not your data. Keep those two recovery problems separate or you'll waste an afternoon restoring the wrong thing.
One more boundary worth stating early: a DACPAC is also not a backup. If the database is your real loss, restore a full backup first and regenerate the DACPAC afterward. Reversing that order gains nothing.
Route 1: Regenerate it from the live database with SqlPackage
This is the fastest route when the database still exists on any reachable SQL Server instance. The tool is SqlPackage, shipped as a .NET global tool or as a standalone download from Microsoft, and it works the same way whether you run it on Windows, Linux, or macOS.
Prerequisites: network access to the instance, an account with permission to read the database schema (db_owner or equivalent metadata visibility works; a user with only db_datareader will produce a partial or failing extraction), and SqlPackage installed. Confirm it is present with sqlpackage /version in a terminal.
1: Open a command prompt or terminal. 2: Run the extract action against the database. A typical call looks like sqlpackage /Action:Extract /SourceServerName:localhost /SourceDatabaseName:MyApp /TargetFile:"C:\temp\MyApp.dacpac". 3: If the instance uses SQL authentication, add /SourceUser: and /SourcePassword:, or prefer /SourceTrustServerCertificate:True on test boxes with self-signed certificates. 4: Watch for the "Extraction complete" style success message and a non-zero file size. 5: Verify by opening the file's properties: a real DACPAC for a mid-sized schema lands in the low hundreds of kilobytes to a few megabytes. A 1 KB file means the extraction failed silently.
Success check: rename a copy to .zip and confirm the archive contains model.xml and a [Content_Types].xml entry. Failure handling: the common errors are login failures (fix the connection string), "The server principal is not able to access the database" (grant permissions), and timeouts on large schemas (raise /CommandTimeout). If extraction reports unsupported objects, you'll still get the core schema, but review the log before trusting it.
Route 2: Extract from an SSDT project in Visual Studio
If your team keeps a database project (a .sqlproj file), you already have the DACPAC's source of truth. SSDT, the SQL Server Data Tools component of Visual Studio, builds the project and emits the .dacpac into the build output folder, usually bin\Debug or bin\Release relative to the .sqlproj.
Prerequisites: Visual Studio with the SQL Server Data Tools workload installed, and the project itself.
1: Open the solution containing the .sqlproj file. 2: Set the build configuration to Release if you want an artifact matching what shipped. 3: Build the project with Build > Build Solution, or right-click the project and choose Build. 4: Look in the output window for the path the build reports, then open that folder in File Explorer. 5: Copy the .dacpac out and store it wherever you need it.
A build is usually 10 to 60 seconds for a typical project, so this route beats hunting for an old file. If the build fails on unresolved references, the project is likely missing a database reference or a variable value — fix that rather than trying to assemble a DACPAC by hand. If you don't have Visual Studio, the .NET SDK plus the Microsoft.Build.Sql project type can build the same project from the command line, though older .sqlproj files may need the full SSDT toolchain.
Route 3: Recover the original from source control, artifact storage, or a colleague's machine
Most "lost" DACPACs were never lost at all — they were generated on a build agent and only the pipeline kept them. Check these locations in this order before doing anything more invasive:
Build artifacts: Azure DevOps, GitHub Actions, Jenkins, and TeamCity all retain published artifacts for a configurable retention period, often 30 to 90 days by default. Open the most recent successful pipeline run and download the artifact. Source control history: if anyone ever committed the .dacpac (not best practice, but common), use git log --all -- "*.dacpac" to find it, then git checkout -- path/to/file.dacpac. Release pipelines and deployment logs: a release that deployed a DACPAC often stored the exact file used, so the run record may contain a downloadable copy. Local developer machines and build agents: search with Get-ChildItem -Path C:\ -Filter *.dacpac -Recurse -ErrorAction SilentlyContinue in PowerShell, ideally scoped to likely roots to keep it fast.
Retention settings are the deciding factor here. If the artifact aged out, ask the pipeline administrator whether the retention policy can be extended for future builds — a useful fix even after this recovery.
Route 4: Restore a database backup, then re-extract
When the live database was dropped or corrupted but you have a backup, the order is fixed: restore first, extract second. Restoring a full backup and then running SqlPackage's Extract on the restored copy produces a faithful DACPAC, and it also lets you confirm the schema you're recovering is the one you expect.
1: Restore the most recent full backup to a scratch instance with RESTORE DATABASE ScratchDB FROM DISK = 'D:\backups\MyApp.bak' WITH MOVE ... or through SQL Server Management Studio's Restore Database dialog. 2: Bring the database online and run a quick sanity query such as SELECT COUNT(*) FROM sys.tables to confirm objects are present. 3: Run the SqlPackage Extract action against ScratchDB, exactly as in Route 1. 4: Verify the .dacpac by opening it as a ZIP, then store it alongside the backup.
If you only have a differential or log backup, you'll need the base full backup plus the chain. A restore that stops with "the log or differential backup cannot be restored because no files are ready" means the chain is broken — locate the missing piece rather than forcing WITH RECOVERY early.
Route 5: Salvage the file from deployment history on the server
SQL Server keeps a record of every DACPAC deployment. The dbo.__DeploymentLog and the related registration tables on the target database often survive even when the original file is gone, and they can help you reconstruct what was deployed, though not always the archive itself.
1: Query SELECT * FROM dbo.__DeploymentLog on the target database to see what was deployed and when. 2: Check the DAC registration entries in msdb, which record deployment metadata. 3: If you have the deployment script (SqlPackage can generate one with /Action:Script), re-running it against an empty scratch database rebuilds the schema, and you can then extract a DACPAC from that scratch database.
This route is reconstruction, not recovery. Databases can't be re-created exactly, so some settings may differ from the original. Treat the rebuilt DACPAC as a close substitute and diff it against a known-good schema using SqlPackage's /Action:DeployReport before trusting it in production.
If the file was deleted and no copy exists anywhere
Before concluding it's gone, check two places people forget. First, the Windows Recycle Bin and File History or Volume Shadow Copy — right-click the folder, choose Properties, then Previous Versions, and restore from a snapshot. Second, cloud sync services: OneDrive and Dropbox keep version history for 30 days on personal plans and longer on business plans.
If those fail, general-purpose file undelete tools can sometimes recover a recently deleted .dacpac from a local disk, but stop writing to that drive immediately to avoid overwriting the sectors. Success rates drop sharply once the machine has been used for anything else, and there's no professional service worth invoking for a file that can be regenerated from any surviving copy of the schema. The stop condition is simple: once the database, source control, backups, and build artifacts are all gone, the schema itself is the loss, and no recovery tool fixes that.
Warnings that cost people their recovery
Three mistakes recur and each one can eliminate your best option.
Extracting from a database you're about to drop. Run the extract first, confirm the .dacpac opens as a ZIP, then drop. Doing it the other way around turns Route 1 into Route 4, which needs a backup you may not have. Regenerating with the wrong schema version. If the database has drifted since the last deployment, a new extract captures the drifted state, not what shipped. Compare against source control before calling it the recovered file. Trusting file-undelete before artifact storage. People delete the DACPAC from a workstation drive that has nothing to do with the pipeline copy. Check the pipeline and source control first; retrieval from those is immediate and free.
How the routes compare on time, risk, and prerequisites
| Route | Time to a usable file | Key prerequisite | Main risk |
|---|---|---|---|
| SqlPackage extract | 1–5 minutes | Live database reachable | Captures current, possibly drifted schema |
| SSDT project build | 10–60 seconds | .sqlproj in source control | Build references unresolved |
| Artifact or git recovery | 2–15 minutes | Retention window still open | Artifact aged out or was never published |
| Backup restore then extract | 30 minutes to several hours | Valid full backup chain | Missing log/differential breaks the chain |
| Deployment-log reconstruction | 1–3 hours | Deployment records and scripts | Schema may not match exactly |
For most people reading this, Route 1 or Route 2 ends the problem inside five minutes. Routes 4 and 5 exist for teams whose database is also gone, and they carry materially more risk of a near-miss instead of a true match.
What one deployment costs you if you skip backups of the artifact
A quick worked example shows why artifact retention matters. Suppose a pipeline publishes the DACPAC on every commit and retains artifacts for 30 days. That gives you roughly 30 days of recovery window for free. If this incident started 45 days after the last build and the live database was dropped 10 days ago with a nightly backup, your recovery is one restore (maybe 40 minutes for a 20 GB database on local storage) plus one extract (2 minutes), totaling under an hour of hands-on work. Without that nightly backup, you're down to source control, and any schema change applied directly in production is unrecoverable. A nightly full backup and a 90-day artifact retention policy would have covered both eventualities; what you're paying for is the difference between an hour and a lost schema.
FAQ
Can I open or edit a DACPAC directly? You can inspect it by renaming it to .zip and unzipping, but editing the XML then re-zipping rarely produces a valid archive. Use SqlPackage or SSDT to regenerate it instead.
Does a DACPAC contain data? No. It contains schema and, when explicitly exported, security objects. Table rows are not included, so pair schema recovery with a data backup strategy.
Can I extract a DACPAC from a database backup file without restoring it? Not with standard tooling. SqlPackage needs a live catalog, so restore the backup to a scratch instance first; that also gives you a chance to verify the backup before you depend on it.
What if I only have the .dacpac and lost the database? SqlPackage's /Action:Publish against an empty target database reconstructs the schema, after which you can restore data from your backup. The DACPAC alone won't bring rows back.