Skip to main content

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​

PhaseWhat you doOutput
BackupExport DB + note versionsRollback artifact
SnapshotCapture plugins/pages/theme modsBefore/after diff
ImportRun Site Library importNew baseline
VerifyCheck pages, menus, layout, pluginsConfidence

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​

PracticeWhy
Import on staging firstReduces risk
Always export DBEnables rollback
Verify logged-outCaching differs logged-in
Record plugin additionsImports often add plugins
Verify front page + menusImports often change homepage assignment

Troubleshooting​

SymptomCauseFix
Import failsPermissions or networkCheck web user write access and retry
Content missingPartial importRe-run import on fresh staging or restore backup
Layout brokenMissing dependencyActivate required plugin(s) and re-test
Wrong homepage after importSite options changedCheck show_on_front and page_on_front and set explicitly

Hands-On​

  1. Export the database before import.
  2. Run one import on staging.
  3. Roll back using wp db import.
  4. Re-run the import and document what changed.
  5. Confirm the correct home page is set and that menus are assigned.
  6. 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​