Roots Discourse

Using WP Migrate DB Pro CLI with Path Variable

In bedrock ansible installation, the --path flag doesn’t seem to be working for migratedb cli command:

web@server$ /usr/bin/wp migratedb profile 5 --path=/srv/www/example.com/current

Warning: No WordPress install found. If the command 'migratedb profile 5' is in a plugin or theme, pass --path=`path/to/wordpress`.

Error: 'migratedb' is not a registered wp command. See 'wp help' for available commands.

$ which wp
/usr/bin/wp

It works fine if run from /srv/www/example.com/current directory without path flag.

Am I doing something wrong?

Try using --path=/srv/www/example.com/current/web/wp

Does that work?

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' mike@mzoo.org" | 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.

This topic was automatically closed after 42 days. New replies are no longer allowed.