This guide covers the working commands and workflows for WP Sync DB CLI, based on tested implementations.

Getting Connection Information

To get your connection token from the current WordPress installation:

bashCopywp wpsdb connection-info

This will output a token like: fJJP3F7g1oPc8/iDoGuo0SKHjSxWLTQu

Creating Profiles

Create a Test Profile (Limited Tables)

bashCopywp wpsdb create-profile PullLiveTest --remote-wordpress=https://your-site.com --token=YOUR_TOKEN --migrate-tables=wp_options,wp_posts

This creates a profile that will only migrate specific tables, which is useful for testing.

Parameters explained:

  • PullLiveTest: Name of your profile
  • --remote-wordpress: The URL of the remote site
  • --token: The connection token from the remote site
  • --migrate-tables: Comma-separated list of tables to migrate

Create a Full Profile

bashCopywp wpsdb create-profile PullLive --remote-wordpress=https://your-site.com --token=YOUR_TOKEN

This creates a profile that will migrate all tables.

Running Migrations

To run a migration using a profile:

bashCopywp wpsdb migrate 1

Note: Use the profile ID number, not the profile name.

Additional Profile Options

You can use these additional flags when creating profiles:

Exclude Post Types

bashCopywp wpsdb create-profile ProfileName --remote-wordpress=https://your-site.com --token=YOUR_TOKEN --exclude-post-types=page

Create Backups During Migration

bashCopywp wpsdb create-profile ProfileName --remote-wordpress=https://your-site.com --token=YOUR_TOKEN --create_backup=true

Best Practices

  1. Always start with a test profile using limited tables
  2. Create backups before running full migrations
  3. Consider table size when selecting tables to migrate
  4. Use specific table migrations for focused updates

Troubleshooting

If you encounter “Profile ID not found”:

  • Make sure you’re using the numeric ID of the profile
  • Try creating a new profile if uncertain about existing IDs

For memory issues:

  • Start with smaller table sets
  • Increase PHP memory limit if necessary
  • Consider breaking large migrations into smaller chunks

Example Workflow

  1. Get connection info from remote site:
bashCopywp wpsdb connection-info
  1. Create test profile:
bashCopywp wpsdb create-profile TestMigration --remote-wordpress=https://your-site.com --token=YOUR_TOKEN --migrate-tables=wp_options
  1. Run test migration:
bashCopywp wpsdb migrate 1
  1. If successful, create full profile:
bashCopywp wpsdb create-profile FullMigration --remote-wordpress=https://your-site.com --token=YOUR_TOKEN --create_backup=true
  1. Run full migration:
bashCopywp wpsdb migrate 2

Remember to always verify your database connection and backup your data before running migrations.