Staging And Backup Guidance
Running SEO operations on a live WordPress site carries inherent risk. This page covers staging workflows, backup strategies, and rollback procedures.
Staging Workflow
Option 1: Local Staging Clone
Create a staging copy of the production site on the same server:
# Clone production to staging directory
wp db export /tmp/prod-backup.sql --path=/var/www/production
wp db create --path=/var/www/staging
wp db import /tmp/prod-backup.sql --path=/var/www/staging
Then run wp-seo-ops against the staging path:
seo-ops audit full --path=/var/www/staging --format=md --output=staging-audit.md
seo-ops meta bulk updates.csv --path=/var/www/staging --dry-run
seo-ops meta bulk updates.csv --path=/var/www/staging
Validate on staging, then export the changes:
seo-ops meta export --path=/var/www/staging --output=staging-changes.csv
Apply the same CSV to production:
seo-ops meta import staging-changes.csv --path=/var/www/production --dry-run
seo-ops meta import staging-changes.csv --path=/var/www/production
Option 2: Separate Staging Server
If you have a separate staging server:
# On staging
seo-ops meta bulk updates.csv --path=/var/www/staging
# After validation, copy the same CSV to production
scp updates.csv user@prod-server:/tmp/
ssh user@prod-server
seo-ops meta import /tmp/updates.csv --path=/var/www/production --dry-run
seo-ops meta import /tmp/updates.csv --path=/var/www/production
Backup Before Production Changes
Full Database Backup
Before any destructive operation, dump the relevant database:
# Full database (use with WP-CLI)
wp db export seo-before-$(date +%Y-%m-%d-%H%M).sql --path=/var/www/html
# Or just the relevant tables (postmeta + plugin tables)
wp db export \
--tables=$(wp db tables --path=/var/www/html --all-tables-with-prefix \
| tr '\n' ',' \
| grep -oP 'wp_postmeta,wp_redirection_items|wp_posts' \
| tr '\n' ',') \
seo-tables-before.sql \
--path=/var/www/html
Metadata Export
Always export current SEO metadata before batch changes:
seo-ops meta export --path=/var/www/html --output=meta-backup-$(date +%Y-%m-%d).csv
Redirect Export
seo-ops redirect export --path=/var/www/html --output=redirects-backup-$(date +%Y-%m-%d).csv
Rollback Procedures
Rollback Single Meta Change
If meta set wrote the wrong value, restore from the backup CSV:
# Find the original value in the backup
grep "^123," meta-backup-2024-12-15.csv
# Restore it
seo-ops meta set 123 title "Original Title" --path=/var/www/html --dry-run
seo-ops meta set 123 title "Original Title" --path=/var/www/html
Rollback Bulk Meta Change
Restore from the pre-change export:
# The pre-change export IS the rollback file
seo-ops meta import meta-backup-2024-12-15.csv --path=/var/www/html --dry-run
seo-ops meta import meta-backup-2024-12-15.csv --path=/var/www/html
Rollback Redirect Import
If a redirect import creates bad rules:
# List all redirects to identify the new ones
seo-ops redirect list --path=/var/www/html
# Delete problematic rules
seo-ops redirect delete 47 --path=/var/www/html --yes
seo-ops redirect delete 48 --path=/var/www/html --yes
# Or restore from backup export
seo-ops redirect import redirects-backup-2024-12-15.csv --path=/var/www/html --overwrite
Rollback With Full Database Restore
If things go seriously wrong:
# Restore the full database dump
wp db import seo-before-2024-12-15-1430.sql --path=/var/www/html
A full database restore overwrites ALL changes made since the backup, not just SEO changes. Use only when absolutely necessary.
Automated Backup Script
Save this as scripts/backup-before-seo.sh:
#!/bin/bash
PATH=/var/www/html
DATE=$(date +%Y-%m-%d-%H%M)
BACKUP_DIR=~/seo-backups
mkdir -p "$BACKUP_DIR"
echo "=== SEO Backup $DATE ==="
# 1. Database dump (wp_postmeta + redirect tables)
echo "Backing up database..."
wp db export "$BACKUP_DIR/full-$DATE.sql" --path=$PATH 2>/dev/null
# 2. Meta export
echo "Backing up SEO metadata..."
seo-ops meta export --path=$PATH --output="$BACKUP_DIR/meta-$DATE.csv"
# 3. Redirect export
echo "Backing up redirects..."
seo-ops redirect export --path=$PATH --output="$BACKUP_DIR/redirects-$DATE.csv"
# 4. Current audit snapshot
echo "Backing up audit state..."
seo-ops audit full --path=$PATH --format=json --output="$BACKUP_DIR/audit-$DATE.json"
echo "Backup complete: $BACKUP_DIR"
Run before any SEO operation:
bash scripts/backup-before-seo.sh
Environment Strategy
| Environment | wp-seo-ops Usage | Backup Needed? |
|---|---|---|
| Local dev | Full read/write | No (throwaway) |
| Staging | Full read/write | Recommended |
| Production | Dry-run first, write after review | Always |
| CI/CD pipeline | Automation scripts | Yes, as pipeline step |
Checklist Before Production Writes
- Test commands on staging first
- Run
--dry-runand review output - Export current metadata (
meta export) - Export current redirects (
redirect export) - Dump relevant database tables
- Confirm
--pathis correct (not pointing to staging) - Confirm SEO plugin detection is correct (
inventory) - Apply in small batches
- Validate after each batch