Leveraging WP-CLI Aliases in Your WordPress Development Workflow

If you’re looking for an example script that does the opposite of what’s in the post, going from development to production (useful during initial solo-dev), here’s sync-dev-to-prod-FOR-REAL.sh :slight_smile: :

read -r -p "Would you really like to reset THE PRODUCTION DATABASE and send up the latest from dev? [y/N] " response
if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]
then
    wp @development db export - > sql-dump-development.sql
    scp sql-dump-development.sql web@example.com:/srv/www/example.com/current

    wp @production db export just-in-case.sql
    wp @production db reset --yes

    wp @production db import sql-dump-development.sql
    wp @production search-replace https://example.dev http://example.com
    scp -r web/app/uploads/ web@example.com:/srv/www/example.com/shared
else
    exit 0
fi

8 Likes