Using WP Migrate DB Pro CLI with Path Variable

That’s the solution, @codepuncher. Thanks you.

/usr/bin/wp migratedb profile 6 --path=/srv/www/example.com/current/web/wp

So if I wanted to run a cron job I think it would look like:

0 0 * * * web /usr/bin/wp migratedb profile 6 --path=/srv/www/example.com/current/web/wp > /dev/null 2>&1

Where 6 is the id shown in the query string as the wpmdb-profile ID. I don’t believe this needs to be run by the web user, but it probably makes sense to run as web. On my trellis-provisioned and deployed server the cron.d files are owned by root.

I also discovered the at command today which seems great for single scheduled processes:

echo "echo 'It has been a minute' | mail -s 'Greetings from Echo via At' [email protected]" | at now + 1 min

Or in the case of migratedb:

echo "/usr/bin/wp migratedb profile 6 --path=/srv/www/example.com/current/web/wp" | at now + 30 min 

Not all Linux installs include at, but this Ubuntu 16 does.

1 Like