Umbraco新手咨询:如何将生产环境内容反向同步至本地数据库?
Reverse Sync Production Umbraco Content to Local Database
Hey there! I totally get where you're coming from—when you're new to Umbraco, figuring out environment sync workflows can feel tricky. Let's walk through the most reliable ways to pull content from your production instance back to your local database:
1. Use Umbraco's Built-In Export/Import Tool (Best for Selective Content)
This is great if you don't need to sync the entire database, just specific content nodes, media, or members:
- Step 1: Export from Production
Log into your production Umbraco backoffice, navigate to the Content section. Right-click the root content node (or any specific node you want to sync) and select Export.- Check the boxes for content types, media, members, or other data you want to include in the export.
- Generate and download the
.udt(Umbraco Data Transfer) file.
- Step 2: Import to Local
In your local Umbraco backoffice, go to Settings > Data Transfer > Import.- Upload the
.udtfile you downloaded, then follow the on-screen prompts to map any content types or properties if needed.
- Upload the
- Bonus: Sync Media Files
Don't forget to copy thewwwroot/mediafolder from your production server to your local project's corresponding directory—this ensures all images/documents show up correctly.
2. Full Database Backup & Restore (Best for Complete Sync)
If you need an exact copy of your production database locally, this method is straightforward:
- Step 1: Backup Production Database
Use your database management tool (like SSMS for SQL Server) to create a full backup of your production Umbraco database. Save the.bakfile locally. - Step 2: Restore to Local Database
In your local database server, restore the.bakfile. Make sure to adjust the database file paths (MDF/LDF) to point to your local storage to avoid conflicts with existing databases. - Step 3: Update Local Configuration
- Replace your local project's
wwwroot/mediafolder with the one from production. - Update your local
appsettings.jsonto use the connection string for the restored database (if you didn't overwrite your existing local database).
- Replace your local project's
- Quick Fix: Reset Admin Password
After restoring, you might not know the production admin password. Run this SQL query on your local database to reset it (replaceYOUR_NEW_HASHwith a valid Umbraco password hash—you can generate one by creating a test user locally and copying its hash from theumbracoUsertable):UPDATE umbracoUser SET userPassword = 'YOUR_NEW_HASH' WHERE id = 1;
3. Umbraco Deploy (Best for Team/Incremental Sync)
If you're using Umbraco's official deployment tool (Umbraco Deploy, included with Umbraco Cloud or available as a paid license), you can set up reverse sync for incremental updates:
- Step 1: Verify Deploy Setup
Ensure Umbraco Deploy is configured on both production and local environments. In the production backoffice, every content node should have a Deploy identifier (check the top-right corner of the content editor). - Step 2: Pull Content to Local
In your local Umbraco backoffice, open the Deploy panel. Select Pull from Remote, choose your production environment as the source, then pick the content nodes you want to sync.- This method only pulls changes made since your last sync, which is perfect for ongoing development.
Key Notes to Avoid Headaches
- Always make sure your local Umbraco version matches the production version—version mismatches can break content sync or cause unexpected errors.
- Before syncing, double-check that custom content types, data types, and templates are identical on both environments. If local is missing a type, imports/restore will fail.
- For media sync, tools like
robocopy(Windows) orrsync(Mac/Linux) can automate copying themediafolder, saving you manual work.
内容的提问来源于stack exchange,提问作者Maarten Kieft
相关产品推荐
相关产品推荐

