Import Workflow
warning
Imports are destructive in practice because they overwrite content and settings. Always export the database before importing on any non-throwaway site.
Prerequisites
| Phase | What you do | Output |
|---|---|---|
| Backup | Export DB + note versions | Rollback artifact |
| Snapshot | Capture plugins/pages/theme mods | Before/after diff |
| Import | Run Site Library import | New baseline |
| Verify | Check pages, menus, layout, plugins | Confidence |
Safety Notes
- You need an audit trail when imports change dozens of things.
- Rollback must be tested, not assumed.
- Caching can hide failures until users hit the site.
How It Works
Site Library uses the WordPress import mechanisms plus plugin installs and setting changes. Your workflow wraps that with safety controls.
Step-by-Step Import
Step 1: Export the Database (Rollback)
backup-db-before-import.sh
cd /var/www/html
wp db export /tmp/wp-before-site-library.sql
ls -lh /tmp/wp-before-site-library.sql
Step 2: Snapshot Key State
snapshot-before-import.sh
cd /var/www/html
wp plugin list --status=active > /tmp/wp-active-plugins.before.txt
wp post list --post_type=page --fields=ID,post_title,post_status --format=table > /tmp/wp-pages.before.txt
wp option get theme_mods_generatepress --format=json > /tmp/theme_mods_generatepress.before.json
wp option get show_on_front > /tmp/show_on_front.before.txt
wp option get page_on_front > /tmp/page_on_front.before.txt
Step 3: Run the Import (UI Step)
Run the import via WP admin (Site Library UI). During import:
- Note which plugins are installed
- Note which template was selected
Step 4: Verify After Import
snapshot-after-import.sh
cd /var/www/html
wp plugin list --status=active > /tmp/wp-active-plugins.after.txt
wp post list --post_type=page --fields=ID,post_title,post_status --format=table > /tmp/wp-pages.after.txt
wp option get theme_mods_generatepress --format=json > /tmp/theme_mods_generatepress.after.json
wp option get show_on_front > /tmp/show_on_front.after.txt
wp option get page_on_front > /tmp/page_on_front.after.txt
Step 5: Diff and Document
diff-import-changes.sh
diff -u /tmp/wp-active-plugins.before.txt /tmp/wp-active-plugins.after.txt | head -n 160
diff -u /tmp/wp-pages.before.txt /tmp/wp-pages.after.txt | head -n 160
diff -u /tmp/show_on_front.before.txt /tmp/show_on_front.after.txt | head -n 40
diff -u /tmp/page_on_front.before.txt /tmp/page_on_front.after.txt | head -n 40
caution
If you import on a cached site, purge LSCache after finishing. Otherwise you may not see the true post-import output.
Optional Configuration
Example 1: Roll Back the Import (Staging Drill)
rollback-db-import.sh
cd /var/www/html
wp db import /tmp/wp-before-site-library.sql
wp cache flush 2>/dev/null || true
Outcome: you can prove rollback works before you touch production.
Example 2: Capture a "Template Selection" Note
Store:
- Template name
- Import timestamp
- Plugin list after import
This becomes your change ticket.
Best Practices
| Practice | Why |
|---|---|
| Import on staging first | Reduces risk |
| Always export DB | Enables rollback |
| Verify logged-out | Caching differs logged-in |
| Record plugin additions | Imports often add plugins |
| Verify front page + menus | Imports often change homepage assignment |
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
| Import fails | Permissions or network | Check web user write access and retry |
| Content missing | Partial import | Re-run import on fresh staging or restore backup |
| Layout broken | Missing dependency | Activate required plugin(s) and re-test |
| Wrong homepage after import | Site options changed | Check show_on_front and page_on_front and set explicitly |
Hands-On
- Export the database before import.
- Run one import on staging.
- Roll back using
wp db import. - Re-run the import and document what changed.
- Confirm the correct home page is set and that menus are assigned.
- Purge LSCache and verify the site logged-out.
Quick Reference
import-workflow-cheatsheet.sh
cd /var/www/html
wp db export /tmp/wp-before-import.sql
wp plugin list --status=active > /tmp/plugins.before.txt
What's Next
- Next: Reusable Layouts
- Related: Site Library Overview